basklee-nuxt 0.0.0-stage → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (538) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1190 -2
  3. package/bin/basklee-nuxt.mjs +173 -0
  4. package/package.json +69 -4
  5. package/runtime/api.mjs +14 -0
  6. package/runtime/domain.mjs +15 -0
  7. package/runtime/marketplace.mjs +905 -0
  8. package/runtime/seo.mjs +17 -0
  9. package/src/asset-loading-plugin.mjs +10 -0
  10. package/src/favicon-handler.mjs +12 -0
  11. package/src/install.mjs +361 -0
  12. package/src/migrate.mjs +124 -0
  13. package/src/module.d.ts +3 -0
  14. package/src/module.mjs +88 -0
  15. package/src/project-readme.mjs +702 -0
  16. package/src/service.mjs +186 -0
  17. package/src/setup.mjs +250 -0
  18. package/src/sitemap.mjs +93 -0
  19. package/src/update.mjs +54 -0
  20. package/src/validation.mjs +33 -0
  21. package/templates/.vscode/settings.json +5 -0
  22. package/templates/app/app.vue +52 -0
  23. package/templates/app/assets/css/basklee-tokens.css +21 -0
  24. package/templates/app/assets/css/basklee.css +28 -0
  25. package/templates/app/components/basklee/account/AccountActivity.README.md +31 -0
  26. package/templates/app/components/basklee/account/AccountActivity.vue +61 -0
  27. package/templates/app/components/basklee/account/AccountPromocodes.README.md +50 -0
  28. package/templates/app/components/basklee/account/AccountPromocodes.vue +267 -0
  29. package/templates/app/components/basklee/account/AccountSection.README.md +31 -0
  30. package/templates/app/components/basklee/account/AccountSection.vue +132 -0
  31. package/templates/app/components/basklee/account/ProfileAvatar.vue +139 -0
  32. package/templates/app/components/basklee/account/ProfileDeleteAccount.vue +161 -0
  33. package/templates/app/components/basklee/account/ProfileDetailsForm.vue +182 -0
  34. package/templates/app/components/basklee/account/ProfileEmailSettings.vue +269 -0
  35. package/templates/app/components/basklee/account/ProfilePasswordForm.vue +201 -0
  36. package/templates/app/components/basklee/account/ProfileSignIn.vue +446 -0
  37. package/templates/app/components/basklee/account/SignInHistory.README.md +27 -0
  38. package/templates/app/components/basklee/account/SignInHistory.vue +218 -0
  39. package/templates/app/components/basklee/account/StorefrontLogout.README.md +15 -0
  40. package/templates/app/components/basklee/account/StorefrontLogout.vue +109 -0
  41. package/templates/app/components/basklee/account/StorefrontProfile.README.md +145 -0
  42. package/templates/app/components/basklee/account/StorefrontProfile.vue +168 -0
  43. package/templates/app/components/basklee/account/account.css +1047 -0
  44. package/templates/app/components/basklee/account/profile.css +696 -0
  45. package/templates/app/components/basklee/address/AddressForm.README.md +67 -0
  46. package/templates/app/components/basklee/address/AddressForm.vue +537 -0
  47. package/templates/app/components/basklee/address/StorefrontAddresses.README.md +44 -0
  48. package/templates/app/components/basklee/address/StorefrontAddresses.vue +438 -0
  49. package/templates/app/components/basklee/banners/MainBanner.vue +171 -0
  50. package/templates/app/components/basklee/banners/examples/BannerExample.vue +6 -0
  51. package/templates/app/components/basklee/blog/BlogArticle.README.md +44 -0
  52. package/templates/app/components/basklee/blog/BlogArticle.vue +1023 -0
  53. package/templates/app/components/basklee/blog/BlogCommentForm.README.md +28 -0
  54. package/templates/app/components/basklee/blog/BlogCommentForm.vue +129 -0
  55. package/templates/app/components/basklee/blog/BlogComments.README.md +36 -0
  56. package/templates/app/components/basklee/blog/BlogComments.vue +373 -0
  57. package/templates/app/components/basklee/blog/BlogPostCard.vue +307 -0
  58. package/templates/app/components/basklee/blog/BlogPostGroup.vue +108 -0
  59. package/templates/app/components/basklee/blog/StorefrontJournal.README.md +42 -0
  60. package/templates/app/components/basklee/blog/StorefrontJournal.vue +670 -0
  61. package/templates/app/components/basklee/branding/BrandLogos.vue +25 -0
  62. package/templates/app/components/basklee/branding/examples/BrandLogosExample.vue +6 -0
  63. package/templates/app/components/basklee/cart/CartCheckoutDetails.README.md +85 -0
  64. package/templates/app/components/basklee/cart/CartCheckoutDetails.vue +377 -0
  65. package/templates/app/components/basklee/cart/CartDeliverySelector.README.md +95 -0
  66. package/templates/app/components/basklee/cart/CartDeliverySelector.vue +724 -0
  67. package/templates/app/components/basklee/cart/CartItemOptions.README.md +98 -0
  68. package/templates/app/components/basklee/cart/CartItemOptions.vue +693 -0
  69. package/templates/app/components/basklee/cart/CartLineItem.README.md +70 -0
  70. package/templates/app/components/basklee/cart/CartLineItem.vue +271 -0
  71. package/templates/app/components/basklee/cart/CartPreview.README.md +43 -0
  72. package/templates/app/components/basklee/cart/CartPreview.vue +263 -0
  73. package/templates/app/components/basklee/cart/DeliveryMap.README.md +48 -0
  74. package/templates/app/components/basklee/cart/DeliveryMap.vue +155 -0
  75. package/templates/app/components/basklee/cart/StorefrontCart.README.md +89 -0
  76. package/templates/app/components/basklee/cart/StorefrontCart.vue +689 -0
  77. package/templates/app/components/basklee/catalog/CatalogHeader.vue +681 -0
  78. package/templates/app/components/basklee/catalog/CatalogRepresentative.vue +59 -0
  79. package/templates/app/components/basklee/catalog/StorefrontCatalog.README.md +35 -0
  80. package/templates/app/components/basklee/catalog/StorefrontCatalog.vue +179 -0
  81. package/templates/app/components/basklee/catalog/examples/CatalogHeaderExample.vue +6 -0
  82. package/templates/app/components/basklee/categories/CategoryGroup.vue +125 -0
  83. package/templates/app/components/basklee/categories/StorefrontCategory.README.md +60 -0
  84. package/templates/app/components/basklee/categories/StorefrontCategory.vue +277 -0
  85. package/templates/app/components/basklee/categories/examples/CategoryGroupExample.vue +7 -0
  86. package/templates/app/components/basklee/contact/AboutPage.README.md +23 -0
  87. package/templates/app/components/basklee/contact/AboutPage.vue +409 -0
  88. package/templates/app/components/basklee/contact/ContactForm.README.md +29 -0
  89. package/templates/app/components/basklee/contact/ContactForm.vue +289 -0
  90. package/templates/app/components/basklee/contact/EmailUnsubscribe.README.md +27 -0
  91. package/templates/app/components/basklee/contact/EmailUnsubscribe.vue +95 -0
  92. package/templates/app/components/basklee/contact/StorefrontContact.README.md +18 -0
  93. package/templates/app/components/basklee/contact/StorefrontContact.vue +89 -0
  94. package/templates/app/components/basklee/contact/examples/ContactExample.vue +6 -0
  95. package/templates/app/components/basklee/currencies/MainCurrencySwitcher.vue +80 -0
  96. package/templates/app/components/basklee/currencies/examples/CurrencyExample.vue +6 -0
  97. package/templates/app/components/basklee/events/EventEnrollmentDialog.README.md +58 -0
  98. package/templates/app/components/basklee/events/EventEnrollmentDialog.vue +294 -0
  99. package/templates/app/components/basklee/events/EventsBlock.vue +138 -0
  100. package/templates/app/components/basklee/events/examples/EventsExample.vue +6 -0
  101. package/templates/app/components/basklee/legal/CookieNotice.README.md +34 -0
  102. package/templates/app/components/basklee/legal/CookieNotice.vue +84 -0
  103. package/templates/app/components/basklee/legal/StorefrontPrivacy.README.md +35 -0
  104. package/templates/app/components/basklee/legal/StorefrontPrivacy.vue +124 -0
  105. package/templates/app/components/basklee/locale/MainLanguageSwitcher.vue +506 -0
  106. package/templates/app/components/basklee/locale/examples/LocaleExample.vue +6 -0
  107. package/templates/app/components/basklee/manufacturers/ManufacturerIndex.README.md +36 -0
  108. package/templates/app/components/basklee/manufacturers/ManufacturerIndex.vue +495 -0
  109. package/templates/app/components/basklee/manufacturers/StorefrontManufacturers.README.md +30 -0
  110. package/templates/app/components/basklee/manufacturers/StorefrontManufacturers.vue +263 -0
  111. package/templates/app/components/basklee/orders/OrderDetails.README.md +39 -0
  112. package/templates/app/components/basklee/orders/OrderDetails.vue +1074 -0
  113. package/templates/app/components/basklee/orders/OrderPaymentForm.README.md +59 -0
  114. package/templates/app/components/basklee/orders/OrderPaymentForm.vue +73 -0
  115. package/templates/app/components/basklee/orders/StorefrontOrders.README.md +39 -0
  116. package/templates/app/components/basklee/orders/StorefrontOrders.vue +869 -0
  117. package/templates/app/components/basklee/orders/orders.css +612 -0
  118. package/templates/app/components/basklee/payments/PaymentPanel.README.md +76 -0
  119. package/templates/app/components/basklee/payments/PaymentPanel.vue +108 -0
  120. package/templates/app/components/basklee/products/HoverImageViewer.vue +190 -0
  121. package/templates/app/components/basklee/products/ProductCard.README.md +63 -0
  122. package/templates/app/components/basklee/products/ProductCard.vue +911 -0
  123. package/templates/app/components/basklee/products/ProductCardActions.README.md +33 -0
  124. package/templates/app/components/basklee/products/ProductCardActions.vue +412 -0
  125. package/templates/app/components/basklee/products/ProductCardBadges.vue +83 -0
  126. package/templates/app/components/basklee/products/ProductCardDescription.vue +46 -0
  127. package/templates/app/components/basklee/products/ProductCardFavorite.vue +99 -0
  128. package/templates/app/components/basklee/products/ProductCardPrice.vue +66 -0
  129. package/templates/app/components/basklee/products/ProductCardRating.vue +65 -0
  130. package/templates/app/components/basklee/products/ProductCardSeller.vue +66 -0
  131. package/templates/app/components/basklee/products/ProductCardStockNotice.vue +43 -0
  132. package/templates/app/components/basklee/products/ProductCardTitle.vue +46 -0
  133. package/templates/app/components/basklee/products/ProductCardVariants.vue +388 -0
  134. package/templates/app/components/basklee/products/ProductGroup.vue +259 -0
  135. package/templates/app/components/basklee/products/ProductPreorderDialog.README.md +22 -0
  136. package/templates/app/components/basklee/products/ProductPreorderDialog.vue +471 -0
  137. package/templates/app/components/basklee/products/ProductReviewForm.README.md +39 -0
  138. package/templates/app/components/basklee/products/ProductReviewForm.vue +312 -0
  139. package/templates/app/components/basklee/products/ProductReviewGallery.README.md +28 -0
  140. package/templates/app/components/basklee/products/ProductReviewGallery.vue +141 -0
  141. package/templates/app/components/basklee/products/ProductReviewImageViewer.README.md +52 -0
  142. package/templates/app/components/basklee/products/ProductReviewImageViewer.vue +425 -0
  143. package/templates/app/components/basklee/products/ProductReviews.README.md +70 -0
  144. package/templates/app/components/basklee/products/ProductReviews.vue +1025 -0
  145. package/templates/app/components/basklee/products/ProductSecondaryVariantModal.vue +460 -0
  146. package/templates/app/components/basklee/products/ProductSpecificationsDialog.README.md +65 -0
  147. package/templates/app/components/basklee/products/ProductSpecificationsDialog.vue +174 -0
  148. package/templates/app/components/basklee/products/StorefrontProduct.README.md +52 -0
  149. package/templates/app/components/basklee/products/StorefrontProduct.vue +1468 -0
  150. package/templates/app/components/basklee/products/StorefrontWishlist.README.md +33 -0
  151. package/templates/app/components/basklee/products/StorefrontWishlist.vue +290 -0
  152. package/templates/app/components/basklee/products/examples/FeaturedExample.vue +6 -0
  153. package/templates/app/components/basklee/products/examples/FeaturedHoverImageViewerExample.vue +14 -0
  154. package/templates/app/components/basklee/products/examples/FeaturedProductCardActionsExample.vue +14 -0
  155. package/templates/app/components/basklee/products/examples/FeaturedProductCardBadgesExample.vue +14 -0
  156. package/templates/app/components/basklee/products/examples/FeaturedProductCardDescriptionExample.vue +14 -0
  157. package/templates/app/components/basklee/products/examples/FeaturedProductCardExample.vue +14 -0
  158. package/templates/app/components/basklee/products/examples/FeaturedProductCardFavoriteExample.vue +14 -0
  159. package/templates/app/components/basklee/products/examples/FeaturedProductCardPriceExample.vue +14 -0
  160. package/templates/app/components/basklee/products/examples/FeaturedProductCardRatingExample.vue +14 -0
  161. package/templates/app/components/basklee/products/examples/FeaturedProductCardSellerExample.vue +14 -0
  162. package/templates/app/components/basklee/products/examples/FeaturedProductCardStockNoticeExample.vue +14 -0
  163. package/templates/app/components/basklee/products/examples/FeaturedProductCardTitleExample.vue +14 -0
  164. package/templates/app/components/basklee/products/examples/FeaturedProductCardVariantsExample.vue +14 -0
  165. package/templates/app/components/basklee/products/examples/ProductsExample.vue +6 -0
  166. package/templates/app/components/basklee/products/examples/ProductsHoverImageViewerExample.vue +13 -0
  167. package/templates/app/components/basklee/products/examples/ProductsProductCardActionsExample.vue +13 -0
  168. package/templates/app/components/basklee/products/examples/ProductsProductCardBadgesExample.vue +13 -0
  169. package/templates/app/components/basklee/products/examples/ProductsProductCardDescriptionExample.vue +13 -0
  170. package/templates/app/components/basklee/products/examples/ProductsProductCardExample.vue +13 -0
  171. package/templates/app/components/basklee/products/examples/ProductsProductCardFavoriteExample.vue +13 -0
  172. package/templates/app/components/basklee/products/examples/ProductsProductCardPriceExample.vue +13 -0
  173. package/templates/app/components/basklee/products/examples/ProductsProductCardRatingExample.vue +13 -0
  174. package/templates/app/components/basklee/products/examples/ProductsProductCardSellerExample.vue +13 -0
  175. package/templates/app/components/basklee/products/examples/ProductsProductCardStockNoticeExample.vue +13 -0
  176. package/templates/app/components/basklee/products/examples/ProductsProductCardTitleExample.vue +13 -0
  177. package/templates/app/components/basklee/products/examples/ProductsProductCardVariantsExample.vue +13 -0
  178. package/templates/app/components/basklee/promo/PromoProducts.README.md +45 -0
  179. package/templates/app/components/basklee/promo/PromoProducts.vue +287 -0
  180. package/templates/app/components/basklee/search/MainSearch.vue +340 -0
  181. package/templates/app/components/basklee/search/ProductSearchResults.README.md +81 -0
  182. package/templates/app/components/basklee/search/ProductSearchResults.vue +506 -0
  183. package/templates/app/components/basklee/search/SearchFilters.vue +546 -0
  184. package/templates/app/components/basklee/search/examples/MainSearchExample.vue +6 -0
  185. package/templates/app/components/basklee/sellers/SellerFilters.README.md +32 -0
  186. package/templates/app/components/basklee/sellers/SellerFilters.vue +317 -0
  187. package/templates/app/components/basklee/sellers/SellerPhotoGallery.README.md +45 -0
  188. package/templates/app/components/basklee/sellers/SellerPhotoGallery.vue +406 -0
  189. package/templates/app/components/basklee/sellers/SellerSummary.README.md +33 -0
  190. package/templates/app/components/basklee/sellers/SellerSummary.vue +162 -0
  191. package/templates/app/components/basklee/sellers/StorefrontSellers.README.md +73 -0
  192. package/templates/app/components/basklee/sellers/StorefrontSellers.vue +300 -0
  193. package/templates/app/components/basklee/shared/BaskleeAvatar.README.md +30 -0
  194. package/templates/app/components/basklee/shared/BaskleeAvatar.vue +83 -0
  195. package/templates/app/components/basklee/shared/BaskleeBreadcrumbs.README.md +65 -0
  196. package/templates/app/components/basklee/shared/BaskleeBreadcrumbs.vue +118 -0
  197. package/templates/app/components/basklee/shared/BaskleeEmptyState.README.md +38 -0
  198. package/templates/app/components/basklee/shared/BaskleeEmptyState.vue +143 -0
  199. package/templates/app/components/basklee/shared/BaskleeImage.vue +84 -0
  200. package/templates/app/components/basklee/shared/BaskleeInfoHint.README.md +32 -0
  201. package/templates/app/components/basklee/shared/BaskleeInfoHint.vue +158 -0
  202. package/templates/app/components/basklee/shared/BaskleePasswordInput.README.md +30 -0
  203. package/templates/app/components/basklee/shared/BaskleePasswordInput.vue +197 -0
  204. package/templates/app/components/basklee/shared/BaskleeSearchSelect.README.md +38 -0
  205. package/templates/app/components/basklee/shared/BaskleeSearchSelect.vue +411 -0
  206. package/templates/app/components/basklee/shared/BaskleeSelect.README.md +31 -0
  207. package/templates/app/components/basklee/shared/BaskleeSelect.vue +525 -0
  208. package/templates/app/components/basklee/shared/StorefrontErrorPage.README.md +55 -0
  209. package/templates/app/components/basklee/shared/StorefrontErrorPage.vue +151 -0
  210. package/templates/app/components/basklee/shared/StorefrontPagination.README.md +50 -0
  211. package/templates/app/components/basklee/shared/StorefrontPagination.vue +148 -0
  212. package/templates/app/components/basklee/shared/dialogs.css +36 -0
  213. package/templates/app/components/basklee/shared/features.css +364 -0
  214. package/templates/app/components/basklee/social/SocialLinks.vue +72 -0
  215. package/templates/app/components/basklee/social/examples/SocialLinksExample.vue +6 -0
  216. package/templates/app/components/basklee/storefront/StorefrontAccount.README.md +47 -0
  217. package/templates/app/components/basklee/storefront/StorefrontAccount.vue +332 -0
  218. package/templates/app/components/basklee/storefront/StorefrontCartButton.vue +68 -0
  219. package/templates/app/components/basklee/storefront/StorefrontFooter.README.md +26 -0
  220. package/templates/app/components/basklee/storefront/StorefrontFooter.vue +236 -0
  221. package/templates/app/components/basklee/storefront/StorefrontHeader.README.md +93 -0
  222. package/templates/app/components/basklee/storefront/StorefrontHeader.vue +509 -0
  223. package/templates/app/components/basklee/storefront/StorefrontHome.README.md +79 -0
  224. package/templates/app/components/basklee/storefront/StorefrontHome.vue +315 -0
  225. package/templates/app/components/basklee/storefront/StorefrontWishlistButton.vue +105 -0
  226. package/templates/app/components/basklee/storefront/examples/StorefrontAccountExample.vue +7 -0
  227. package/templates/app/components/basklee/stores/StorefrontStores.README.md +41 -0
  228. package/templates/app/components/basklee/stores/StorefrontStores.vue +346 -0
  229. package/templates/app/components/basklee/subscriptions/StorefrontSubscriptions.README.md +151 -0
  230. package/templates/app/components/basklee/subscriptions/StorefrontSubscriptions.vue +851 -0
  231. package/templates/app/components/basklee/subscriptions/StorefrontTariff.README.md +38 -0
  232. package/templates/app/components/basklee/subscriptions/StorefrontTariff.vue +555 -0
  233. package/templates/app/components/basklee/subscriptions/StorefrontTariffs.README.md +36 -0
  234. package/templates/app/components/basklee/subscriptions/StorefrontTariffs.vue +416 -0
  235. package/templates/app/components/basklee/subscriptions/SubscriptionCancelDialog.README.md +39 -0
  236. package/templates/app/components/basklee/subscriptions/SubscriptionCancelDialog.vue +292 -0
  237. package/templates/app/components/basklee/subscriptions/SubscriptionChangeDialog.README.md +85 -0
  238. package/templates/app/components/basklee/subscriptions/SubscriptionChangeDialog.vue +874 -0
  239. package/templates/app/components/basklee/subscriptions/SubscriptionExtendDialog.README.md +53 -0
  240. package/templates/app/components/basklee/subscriptions/SubscriptionExtendDialog.vue +536 -0
  241. package/templates/app/components/basklee/subscriptions/SubscriptionPlanSummary.README.md +101 -0
  242. package/templates/app/components/basklee/subscriptions/SubscriptionPlanSummary.vue +286 -0
  243. package/templates/app/components/basklee/subscriptions/SubscriptionRemoteDetails.README.md +138 -0
  244. package/templates/app/components/basklee/subscriptions/SubscriptionRemoteDetails.vue +134 -0
  245. package/templates/app/components/basklee/subscriptions/SubscriptionRenewalDialog.README.md +85 -0
  246. package/templates/app/components/basklee/subscriptions/SubscriptionRenewalDialog.vue +364 -0
  247. package/templates/app/components/basklee/support/StorefrontSupport.README.md +39 -0
  248. package/templates/app/components/basklee/support/StorefrontSupport.vue +484 -0
  249. package/templates/app/components/basklee/support/TicketConversation.README.md +38 -0
  250. package/templates/app/components/basklee/support/TicketConversation.vue +524 -0
  251. package/templates/app/components/basklee/support/TicketImage.README.md +27 -0
  252. package/templates/app/components/basklee/support/TicketImage.vue +186 -0
  253. package/templates/app/components/basklee/support/TicketItemCard.README.md +59 -0
  254. package/templates/app/components/basklee/support/TicketItemCard.vue +177 -0
  255. package/templates/app/components/basklee/support/TicketMessageForm.README.md +35 -0
  256. package/templates/app/components/basklee/support/TicketMessageForm.vue +258 -0
  257. package/templates/app/components/basklee/support/TicketSubscriptionCard.README.md +40 -0
  258. package/templates/app/components/basklee/support/TicketSubscriptionCard.vue +154 -0
  259. package/templates/app/components/basklee/tariffs/TariffCard.README.md +12 -0
  260. package/templates/app/components/basklee/tariffs/TariffCard.vue +251 -0
  261. package/templates/app/components/basklee/tariffs/TariffCardDescription.README.md +12 -0
  262. package/templates/app/components/basklee/tariffs/TariffCardDescription.vue +97 -0
  263. package/templates/app/components/basklee/tariffs/TariffCardFeatures.README.md +14 -0
  264. package/templates/app/components/basklee/tariffs/TariffCardFeatures.vue +172 -0
  265. package/templates/app/components/basklee/tariffs/TariffCardImage.README.md +12 -0
  266. package/templates/app/components/basklee/tariffs/TariffCardImage.vue +33 -0
  267. package/templates/app/components/basklee/tariffs/TariffCardPrices.README.md +12 -0
  268. package/templates/app/components/basklee/tariffs/TariffCardPrices.vue +300 -0
  269. package/templates/app/components/basklee/tariffs/TariffCardTitle.README.md +12 -0
  270. package/templates/app/components/basklee/tariffs/TariffCardTitle.vue +30 -0
  271. package/templates/app/components/basklee/tariffs/TariffCards.README.md +12 -0
  272. package/templates/app/components/basklee/tariffs/TariffCards.vue +94 -0
  273. package/templates/app/components/basklee/tariffs/TariffSubscriptionModal.README.md +31 -0
  274. package/templates/app/components/basklee/tariffs/TariffSubscriptionModal.vue +411 -0
  275. package/templates/app/components/basklee/tariffs/examples/TariffCardDescriptionExample.vue +13 -0
  276. package/templates/app/components/basklee/tariffs/examples/TariffCardExample.vue +13 -0
  277. package/templates/app/components/basklee/tariffs/examples/TariffCardFeaturesExample.vue +14 -0
  278. package/templates/app/components/basklee/tariffs/examples/TariffCardImageExample.vue +13 -0
  279. package/templates/app/components/basklee/tariffs/examples/TariffCardPricesExample.vue +13 -0
  280. package/templates/app/components/basklee/tariffs/examples/TariffCardTitleExample.vue +13 -0
  281. package/templates/app/components/basklee/tariffs/examples/TariffCardsExample.vue +6 -0
  282. package/templates/app/components/basklee/theme/BaskleeThemeProvider.vue +38 -0
  283. package/templates/app/components/basklee/units/UnitSwitcher.vue +71 -0
  284. package/templates/app/components/basklee/units/examples/LengthExample.vue +6 -0
  285. package/templates/app/components/basklee/units/examples/WeightExample.vue +6 -0
  286. package/templates/app/components/basklee/wallet/StorefrontWallet.README.md +117 -0
  287. package/templates/app/components/basklee/wallet/StorefrontWallet.vue +863 -0
  288. package/templates/app/components/basklee/wallet/WalletBalance.vue +47 -0
  289. package/templates/app/components/basklee/wallet/WalletTopUpForm.README.md +32 -0
  290. package/templates/app/components/basklee/wallet/WalletTopUpForm.vue +224 -0
  291. package/templates/app/components/basklee/wallet/examples/WalletExample.vue +6 -0
  292. package/templates/app/composables/useBaskleeActionMenu.ts +126 -0
  293. package/templates/app/composables/useBaskleeAddressEditor.ts +343 -0
  294. package/templates/app/composables/useBaskleeAddresses.ts +75 -0
  295. package/templates/app/composables/useBaskleeApi.ts +190 -0
  296. package/templates/app/composables/useBaskleeAppLoad.ts +83 -0
  297. package/templates/app/composables/useBaskleeBlogComments.ts +325 -0
  298. package/templates/app/composables/useBaskleeBlogReading.ts +270 -0
  299. package/templates/app/composables/useBaskleeCart.ts +226 -0
  300. package/templates/app/composables/useBaskleeCartPreview.ts +142 -0
  301. package/templates/app/composables/useBaskleeCategoryLink.ts +24 -0
  302. package/templates/app/composables/useBaskleeCategoryProducts.ts +16 -0
  303. package/templates/app/composables/useBaskleeFeature.ts +100 -0
  304. package/templates/app/composables/useBaskleeFeaturedProducts.ts +14 -0
  305. package/templates/app/composables/useBaskleeGeolocation.ts +28 -0
  306. package/templates/app/composables/useBaskleeHomeProducts.ts +90 -0
  307. package/templates/app/composables/useBaskleeManufacturerIndex.ts +83 -0
  308. package/templates/app/composables/useBaskleeMap.ts +240 -0
  309. package/templates/app/composables/useBaskleeMediaFormat.ts +24 -0
  310. package/templates/app/composables/useBaskleeMissingPage.ts +67 -0
  311. package/templates/app/composables/useBaskleeOrders.ts +185 -0
  312. package/templates/app/composables/useBaskleePageSeo.ts +133 -0
  313. package/templates/app/composables/useBaskleeProductActions.ts +116 -0
  314. package/templates/app/composables/useBaskleeProductLink.ts +24 -0
  315. package/templates/app/composables/useBaskleeProductSearch.ts +363 -0
  316. package/templates/app/composables/useBaskleeProductVariants.ts +176 -0
  317. package/templates/app/composables/useBaskleeProfile.ts +309 -0
  318. package/templates/app/composables/useBaskleeProgress.ts +89 -0
  319. package/templates/app/composables/useBaskleeReviews.ts +242 -0
  320. package/templates/app/composables/useBaskleeSearchHistory.ts +23 -0
  321. package/templates/app/composables/useBaskleeSearchScopeNames.ts +99 -0
  322. package/templates/app/composables/useBaskleeServerData.ts +72 -0
  323. package/templates/app/composables/useBaskleeSignIn.ts +66 -0
  324. package/templates/app/composables/useBaskleeStableHeight.ts +69 -0
  325. package/templates/app/composables/useBaskleeStorefront.ts +29 -0
  326. package/templates/app/composables/useBaskleeSubscriptions.ts +260 -0
  327. package/templates/app/composables/useBaskleeTheme.ts +27 -0
  328. package/templates/app/composables/useBaskleeTicketSubject.ts +180 -0
  329. package/templates/app/composables/useBaskleeTickets.ts +335 -0
  330. package/templates/app/composables/useBaskleeWallet.ts +166 -0
  331. package/templates/app/error.vue +108 -0
  332. package/templates/app/interfaces/basklee/accounts/IContact.ts +21 -0
  333. package/templates/app/interfaces/basklee/accounts/IEmailNotificationLocale.ts +17 -0
  334. package/templates/app/interfaces/basklee/accounts/IEmailVerification.ts +59 -0
  335. package/templates/app/interfaces/basklee/accounts/IProfileActions.ts +38 -0
  336. package/templates/app/interfaces/basklee/accounts/IProfileData.ts +125 -0
  337. package/templates/app/interfaces/basklee/accounts/IProfileMedia.ts +17 -0
  338. package/templates/app/interfaces/basklee/accounts/IStorefrontProfile.ts +54 -0
  339. package/templates/app/interfaces/basklee/address/IAddressCitySuggestion.ts +19 -0
  340. package/templates/app/interfaces/basklee/address/IAddressEditor.ts +9 -0
  341. package/templates/app/interfaces/basklee/address/IAddressLocationSuggestion.ts +22 -0
  342. package/templates/app/interfaces/basklee/address/IAddressRegionSearch.ts +30 -0
  343. package/templates/app/interfaces/basklee/address/IAddressSuggestion.ts +20 -0
  344. package/templates/app/interfaces/basklee/address/IUserAddress.ts +87 -0
  345. package/templates/app/interfaces/basklee/apiBase/TMethod.ts +1 -0
  346. package/templates/app/interfaces/basklee/appBase/IAppLoad.ts +16 -0
  347. package/templates/app/interfaces/basklee/appBase/IAppLoadCommon.ts +47 -0
  348. package/templates/app/interfaces/basklee/appBase/IApploadUserProfile.ts +15 -0
  349. package/templates/app/interfaces/basklee/appBase/IForm.ts +21 -0
  350. package/templates/app/interfaces/basklee/appBase/ISEO.ts +21 -0
  351. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonBanner.ts +11 -0
  352. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonContact.ts +8 -0
  353. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonCurrency.ts +15 -0
  354. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonEvents.ts +18 -0
  355. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonLocale.ts +14 -0
  356. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonLogos.ts +6 -0
  357. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonPath.ts +22 -0
  358. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonSEO.ts +26 -0
  359. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonSocial.ts +15 -0
  360. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonTariff.ts +7 -0
  361. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonUnit.ts +12 -0
  362. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonVariables.ts +8 -0
  363. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonVisualSettings.ts +11 -0
  364. package/templates/app/interfaces/basklee/appBase/appLoadCommon/IAppLoadCommonWalletValue.ts +3 -0
  365. package/templates/app/interfaces/basklee/blog/IBlogApi.ts +247 -0
  366. package/templates/app/interfaces/basklee/blog/IBlogPostPreview.ts +30 -0
  367. package/templates/app/interfaces/basklee/cart/ICartActions.ts +67 -0
  368. package/templates/app/interfaces/basklee/cart/ICartData.ts +382 -0
  369. package/templates/app/interfaces/basklee/cart/ICartDeliveryActions.ts +68 -0
  370. package/templates/app/interfaces/basklee/cart/ICartModal.ts +22 -0
  371. package/templates/app/interfaces/basklee/cart/IDeliveryMap.ts +29 -0
  372. package/templates/app/interfaces/basklee/catalog/ICatalogDirectory.ts +75 -0
  373. package/templates/app/interfaces/basklee/category/ICategory.ts +41 -0
  374. package/templates/app/interfaces/basklee/domains/IDomain.ts +13 -0
  375. package/templates/app/interfaces/basklee/forms/ICustomerSubfilter.ts +19 -0
  376. package/templates/app/interfaces/basklee/index.ts +57 -0
  377. package/templates/app/interfaces/basklee/marketing/IPromoActions.ts +51 -0
  378. package/templates/app/interfaces/basklee/orders/IOrderActions.ts +99 -0
  379. package/templates/app/interfaces/basklee/orders/IOrderHistory.ts +259 -0
  380. package/templates/app/interfaces/basklee/orders/IProductPreorder.ts +31 -0
  381. package/templates/app/interfaces/basklee/payments/IInvoice.ts +147 -0
  382. package/templates/app/interfaces/basklee/products/IProduct.ts +262 -0
  383. package/templates/app/interfaces/basklee/products/IProductFeedbackApi.ts +218 -0
  384. package/templates/app/interfaces/basklee/products/IProductSearchApi.ts +146 -0
  385. package/templates/app/interfaces/basklee/products/IProductSearchFacets.ts +35 -0
  386. package/templates/app/interfaces/basklee/products/IProductSecondaryVariantRequest.ts +15 -0
  387. package/templates/app/interfaces/basklee/products/IProductSpecification.ts +14 -0
  388. package/templates/app/interfaces/basklee/products/IWishlist.ts +22 -0
  389. package/templates/app/interfaces/basklee/sellers/ISellerDirectory.ts +70 -0
  390. package/templates/app/interfaces/basklee/shared/IBreadcrumb.ts +10 -0
  391. package/templates/app/interfaces/basklee/shared/IGeoCoordinates.ts +4 -0
  392. package/templates/app/interfaces/basklee/shared/IStorefrontControls.ts +13 -0
  393. package/templates/app/interfaces/basklee/shared/ITransformValue.ts +3 -0
  394. package/templates/app/interfaces/basklee/state.ts +4 -0
  395. package/templates/app/interfaces/basklee/stores/IStoreDirectory.ts +63 -0
  396. package/templates/app/interfaces/basklee/subscribeOptions/ISubscribeOption.ts +9 -0
  397. package/templates/app/interfaces/basklee/subscribeTariff/ISubscribeTariff.ts +56 -0
  398. package/templates/app/interfaces/basklee/subscribeTariff/ITariffSelection.ts +11 -0
  399. package/templates/app/interfaces/basklee/subscribes/ISubscribe.ts +28 -0
  400. package/templates/app/interfaces/basklee/subscribes/ISubscriptionApi.ts +127 -0
  401. package/templates/app/interfaces/basklee/tickets/ICustomerTicketApi.ts +223 -0
  402. package/templates/app/interfaces/basklee/transport.ts +34 -0
  403. package/templates/app/layouts/default.vue +382 -0
  404. package/templates/app/middleware/00.basklee.global.ts +27 -0
  405. package/templates/app/middleware/01.basklee-sellers.global.ts +15 -0
  406. package/templates/app/middleware/basklee-account.ts +40 -0
  407. package/templates/app/pages/activity.vue +19 -0
  408. package/templates/app/pages/addresses.vue +23 -0
  409. package/templates/app/pages/browse.vue +253 -0
  410. package/templates/app/pages/cart.vue +20 -0
  411. package/templates/app/pages/catalog.vue +17 -0
  412. package/templates/app/pages/category/[id].vue +150 -0
  413. package/templates/app/pages/contact.vue +17 -0
  414. package/templates/app/pages/featured.vue +152 -0
  415. package/templates/app/pages/index.vue +194 -0
  416. package/templates/app/pages/journal/[id].vue +164 -0
  417. package/templates/app/pages/journal/index.vue +74 -0
  418. package/templates/app/pages/logout.vue +71 -0
  419. package/templates/app/pages/manufacturers.vue +33 -0
  420. package/templates/app/pages/orders.vue +40 -0
  421. package/templates/app/pages/privacy.vue +17 -0
  422. package/templates/app/pages/product/[id].vue +150 -0
  423. package/templates/app/pages/profile.vue +118 -0
  424. package/templates/app/pages/promo/[id].vue +67 -0
  425. package/templates/app/pages/promocodes.vue +21 -0
  426. package/templates/app/pages/sellers.vue +203 -0
  427. package/templates/app/pages/stores.vue +36 -0
  428. package/templates/app/pages/subscriptions.vue +21 -0
  429. package/templates/app/pages/tariffs/[slug]/[id].vue +126 -0
  430. package/templates/app/pages/tariffs/index.vue +50 -0
  431. package/templates/app/pages/tickets.vue +56 -0
  432. package/templates/app/pages/unsubscribe.vue +32 -0
  433. package/templates/app/pages/wallet.vue +23 -0
  434. package/templates/app/pages/wishlist.vue +48 -0
  435. package/templates/app/stores/basklee.ts +493 -0
  436. package/templates/app/stores/baskleeBrowse.ts +79 -0
  437. package/templates/app/stores/baskleeCatalog.ts +141 -0
  438. package/templates/app/stores/baskleeDomainAccess.ts +55 -0
  439. package/templates/app/stores/baskleeProducts.ts +249 -0
  440. package/templates/app/stores/baskleeSelections.ts +132 -0
  441. package/templates/app/themes/basklee.ts +108 -0
  442. package/templates/app/utils/basklee/accountLabels.ts +29 -0
  443. package/templates/app/utils/basklee/activityLabels.ts +96 -0
  444. package/templates/app/utils/basklee/activityPresentation.ts +16 -0
  445. package/templates/app/utils/basklee/addressChanges.ts +26 -0
  446. package/templates/app/utils/basklee/addressRegions.ts +17 -0
  447. package/templates/app/utils/basklee/api.ts +333 -0
  448. package/templates/app/utils/basklee/blogArticleHtml.ts +318 -0
  449. package/templates/app/utils/basklee/blogComments.ts +133 -0
  450. package/templates/app/utils/basklee/blogImageViewer.ts +84 -0
  451. package/templates/app/utils/basklee/blogLabels.ts +167 -0
  452. package/templates/app/utils/basklee/blogLayout.ts +108 -0
  453. package/templates/app/utils/basklee/blogProductPlacements.ts +105 -0
  454. package/templates/app/utils/basklee/breadcrumbLabels.ts +14 -0
  455. package/templates/app/utils/basklee/browseLabels.ts +145 -0
  456. package/templates/app/utils/basklee/cartAddress.ts +94 -0
  457. package/templates/app/utils/basklee/cartLabels.ts +390 -0
  458. package/templates/app/utils/basklee/cartOptions.ts +143 -0
  459. package/templates/app/utils/basklee/cartPreview.ts +123 -0
  460. package/templates/app/utils/basklee/cartPromo.ts +150 -0
  461. package/templates/app/utils/basklee/cartShipment.ts +74 -0
  462. package/templates/app/utils/basklee/cartSnapshot.ts +20 -0
  463. package/templates/app/utils/basklee/catalog.ts +106 -0
  464. package/templates/app/utils/basklee/category.ts +52 -0
  465. package/templates/app/utils/basklee/categoryLabels.ts +44 -0
  466. package/templates/app/utils/basklee/contactLabels.ts +152 -0
  467. package/templates/app/utils/basklee/currency.ts +128 -0
  468. package/templates/app/utils/basklee/deliveryMap.ts +89 -0
  469. package/templates/app/utils/basklee/directoryLabels.ts +196 -0
  470. package/templates/app/utils/basklee/emptyStateArt.ts +231 -0
  471. package/templates/app/utils/basklee/errorPageLabels.ts +95 -0
  472. package/templates/app/utils/basklee/featureData.ts +25 -0
  473. package/templates/app/utils/basklee/featureLabels.ts +406 -0
  474. package/templates/app/utils/basklee/featuredLabels.ts +38 -0
  475. package/templates/app/utils/basklee/files.ts +71 -0
  476. package/templates/app/utils/basklee/footerLabels.ts +53 -0
  477. package/templates/app/utils/basklee/guestSession.ts +50 -0
  478. package/templates/app/utils/basklee/headerLabels.ts +98 -0
  479. package/templates/app/utils/basklee/homeContent.ts +129 -0
  480. package/templates/app/utils/basklee/homeLabels.ts +74 -0
  481. package/templates/app/utils/basklee/htmlText.ts +59 -0
  482. package/templates/app/utils/basklee/links.ts +14 -0
  483. package/templates/app/utils/basklee/manufacturerIndex.ts +108 -0
  484. package/templates/app/utils/basklee/modalWindow.ts +109 -0
  485. package/templates/app/utils/basklee/nativeApp.ts +361 -0
  486. package/templates/app/utils/basklee/notice.ts +22 -0
  487. package/templates/app/utils/basklee/orderLabels.ts +454 -0
  488. package/templates/app/utils/basklee/orderPresentation.ts +629 -0
  489. package/templates/app/utils/basklee/pageSeo.ts +662 -0
  490. package/templates/app/utils/basklee/paginationScroll.ts +131 -0
  491. package/templates/app/utils/basklee/phone.ts +22 -0
  492. package/templates/app/utils/basklee/presentation.ts +72 -0
  493. package/templates/app/utils/basklee/privacyLabels.ts +273 -0
  494. package/templates/app/utils/basklee/productActionLabels.ts +108 -0
  495. package/templates/app/utils/basklee/productActions.ts +574 -0
  496. package/templates/app/utils/basklee/productAvailability.ts +36 -0
  497. package/templates/app/utils/basklee/productGallery.ts +72 -0
  498. package/templates/app/utils/basklee/productLabels.ts +119 -0
  499. package/templates/app/utils/basklee/productListLocation.ts +130 -0
  500. package/templates/app/utils/basklee/productManufacturer.ts +30 -0
  501. package/templates/app/utils/basklee/productPage.ts +46 -0
  502. package/templates/app/utils/basklee/productPhotos.ts +67 -0
  503. package/templates/app/utils/basklee/productSearchScope.ts +237 -0
  504. package/templates/app/utils/basklee/productSeller.ts +51 -0
  505. package/templates/app/utils/basklee/productStructuredData.ts +221 -0
  506. package/templates/app/utils/basklee/profile.ts +148 -0
  507. package/templates/app/utils/basklee/profileLabels.ts +229 -0
  508. package/templates/app/utils/basklee/promoLabels.ts +111 -0
  509. package/templates/app/utils/basklee/promoPresentation.ts +381 -0
  510. package/templates/app/utils/basklee/reviewLabels.ts +256 -0
  511. package/templates/app/utils/basklee/reviewScope.ts +41 -0
  512. package/templates/app/utils/basklee/richText.ts +13 -0
  513. package/templates/app/utils/basklee/searchFilters.ts +99 -0
  514. package/templates/app/utils/basklee/searchHistory.ts +144 -0
  515. package/templates/app/utils/basklee/sellerDirectory.ts +134 -0
  516. package/templates/app/utils/basklee/seo.ts +52 -0
  517. package/templates/app/utils/basklee/serverCookies.ts +88 -0
  518. package/templates/app/utils/basklee/sessionLabels.ts +38 -0
  519. package/templates/app/utils/basklee/signInReturn.ts +89 -0
  520. package/templates/app/utils/basklee/storeDirectory.ts +50 -0
  521. package/templates/app/utils/basklee/subscriptionChanges.ts +167 -0
  522. package/templates/app/utils/basklee/subscriptionLabels.ts +100 -0
  523. package/templates/app/utils/basklee/subscriptionManageLabels.ts +424 -0
  524. package/templates/app/utils/basklee/subscriptionPlans.ts +162 -0
  525. package/templates/app/utils/basklee/subscriptionRemote.ts +110 -0
  526. package/templates/app/utils/basklee/subscriptionUsage.ts +82 -0
  527. package/templates/app/utils/basklee/tariffLabels.ts +182 -0
  528. package/templates/app/utils/basklee/tariffPage.ts +77 -0
  529. package/templates/app/utils/basklee/tariffVariables.ts +203 -0
  530. package/templates/app/utils/basklee/tariffs.ts +333 -0
  531. package/templates/app/utils/basklee/ticketItems.ts +87 -0
  532. package/templates/app/utils/basklee/ticketLabels.ts +428 -0
  533. package/templates/app/utils/basklee/ticketLocation.ts +79 -0
  534. package/templates/app/utils/basklee/walletTransaction.ts +135 -0
  535. package/templates/app/utils/baskleeAppLoad.ts +83 -0
  536. package/templates/basklee/COMPONENT-DOWNLOAD.md +40 -0
  537. package/templates/basklee/COMPONENTS.md +1993 -0
  538. package/templates/basklee/THEMES.md +94 -0
@@ -0,0 +1,186 @@
1
+ // Manages the storefront service that "install" set up: start, stop, restart,
2
+ // status, logs and the list of every storefront service on this server.
3
+ // The service is found by its folder (the project root) or by --name.
4
+ import { existsSync } from 'node:fs';
5
+ import { readFile, rm } from 'node:fs/promises';
6
+ import { join, resolve } from 'node:path';
7
+ import { defaultPaths, framework, homeStatus, readApps, runCommand, waitForHttp } from './install.mjs';
8
+
9
+ export const SERVICE_ACTIONS = ['start', 'stop', 'restart', 'status', 'logs', 'list', 'uninstall'];
10
+ // "cleanup" is another name for uninstall.
11
+ export const SERVICE_ALIASES = { cleanup: 'uninstall' };
12
+
13
+ async function frontends(dir) {
14
+ try { return JSON.parse(await readFile(join(dir, 'basklee/settings.json'), 'utf8')).frontends || []; }
15
+ catch { return []; }
16
+ }
17
+
18
+ // The registered storefront of this folder, or the one named with --name.
19
+ export async function findApp({ cwd = process.cwd(), name, paths = defaultPaths } = {}) {
20
+ const apps = await readApps(paths);
21
+ const root = resolve(cwd);
22
+ const app = name ? apps.find(item => item.NAME === name) : apps.find(item => item.DIR === root);
23
+ if (app) return app;
24
+ const known = apps.map(item => item.NAME).join(', ');
25
+ if (name) throw new Error(`No storefront service named ${name}.${known ? ` Installed: ${known}.` : ''}`);
26
+ throw new Error(`${root} is not installed as a service. Install it first: sudo npx basklee-${framework.id} install`
27
+ + (known ? `\nOr name another storefront: --name ${apps[0].NAME} (installed: ${known})` : ''));
28
+ }
29
+
30
+ // true / false; "unknown" when neither systemd nor OpenRC answers.
31
+ async function isRunning(service, { run, systemd }) {
32
+ const result = systemd
33
+ ? await run('systemctl', ['is-active', '--quiet', service], { capture: true })
34
+ : await run('rc-service', [service, 'status'], { capture: true });
35
+ return result.code === 0;
36
+ }
37
+
38
+ async function isEnabled(service, { run, systemd }) {
39
+ const result = systemd
40
+ ? await run('systemctl', ['is-enabled', '--quiet', service], { capture: true })
41
+ : await run('rc-update', ['show', 'default'], { capture: true });
42
+ return systemd ? result.code === 0 : new RegExp(`^\\s*${service}\\s`, 'm').test(result.output);
43
+ }
44
+
45
+ async function lastLogs(app, { run, systemd, paths, lines = 40 }) {
46
+ const result = systemd
47
+ ? await run('journalctl', ['-u', app.SERVICE || `basklee-${app.NAME}`, '-n', String(lines), '--no-pager'], { capture: true })
48
+ : await run('tail', ['-n', String(lines), join(paths.logs, `${app.NAME}.log`)], { capture: true });
49
+ return result.output;
50
+ }
51
+
52
+ // One storefront's state: service, autostart, and the home page as its first domain sees it.
53
+ export async function serviceStatus(app, { run = runCommand, systemd = existsSync('/run/systemd/system'), probe = homeStatus } = {}) {
54
+ const service = app.SERVICE || `basklee-${app.NAME}`;
55
+ const domains = await frontends(app.DIR);
56
+ const running = await isRunning(service, { run, systemd });
57
+ const enabled = await isEnabled(service, { run, systemd });
58
+ const http = running ? await probe(Number(app.PORT), domains[0] || 'localhost') : 0;
59
+ return { name: app.NAME, service, framework: app.FRAMEWORK, dir: app.DIR, port: Number(app.PORT), running, enabled, http, domains };
60
+ }
61
+
62
+ /**
63
+ * controlService({ action, cwd, name, lines, follow }) runs one action and
64
+ * returns what happened; logs and follow print straight to the terminal.
65
+ */
66
+ export async function controlService({
67
+ action, cwd = process.cwd(), name, lines = 100, follow = false,
68
+ paths = defaultPaths, run = runCommand, uid = process.getuid?.(),
69
+ systemd = existsSync('/run/systemd/system'), openrc = existsSync('/sbin/openrc-run'),
70
+ platform = process.platform, probe = homeStatus, wait = waitForHttp, dryRun = false,
71
+ } = {}) {
72
+ action = SERVICE_ALIASES[action] || action;
73
+ if (!SERVICE_ACTIONS.includes(action)) throw new Error(`Unknown service command ${action}. Use ${SERVICE_ACTIONS.join(', ')}.`);
74
+ if (platform !== 'linux') throw new Error(`${action} manages the Linux service that install set up. Run it on your server.`);
75
+ if (!systemd && !openrc) throw new Error('Neither systemd nor OpenRC was found on this server.');
76
+
77
+ if (action === 'list') {
78
+ const apps = await readApps(paths);
79
+ return { action, apps: await Promise.all(apps.map(app => serviceStatus(app, { run, systemd, probe }))) };
80
+ }
81
+
82
+ const app = await findApp({ cwd, name, paths });
83
+ const service = app.SERVICE || `basklee-${app.NAME}`;
84
+ if (action === 'status') return { action, ...await serviceStatus(app, { run, systemd, probe }) };
85
+
86
+ if (action === 'logs') {
87
+ const count = Number(lines);
88
+ if (!Number.isInteger(count) || count < 1) throw new Error('Give the number of log lines as a whole number, for example: logs 200');
89
+ const args = systemd
90
+ ? ['journalctl', ['-u', service, '-n', String(count), '--no-pager', ...(follow ? ['--follow'] : [])]]
91
+ : ['tail', ['-n', String(count), ...(follow ? ['-F'] : []), join(paths.logs, `${app.NAME}.log`)]];
92
+ const result = await run(...args);
93
+ if (result.code) throw new Error(`${args[0]} could not read the logs of ${service}${uid !== 0 ? `; try: sudo npx basklee-${framework.id} logs` : ''}.`);
94
+ return { action, name: app.NAME, service };
95
+ }
96
+
97
+ if (action === 'uninstall') return uninstallService(app, { paths, run, uid, systemd, name, dryRun });
98
+ if (uid !== 0) throw new Error(`${action} needs root: sudo npx basklee-${framework.id} ${action}${name ? ` --name ${name}` : ''}`);
99
+ const result = systemd
100
+ ? await run('systemctl', [action, service], { capture: true })
101
+ : await run('rc-service', [service, action], { capture: true });
102
+ if (result.code) throw new Error(`Could not ${action} ${service}:\n${result.output.trim()}`);
103
+ if (action === 'stop') return { action, name: app.NAME, service, running: false };
104
+
105
+ const domains = await frontends(app.DIR);
106
+ const http = await wait(Number(app.PORT), domains[0] || 'localhost', 90);
107
+ if (!http) {
108
+ throw new Error(`${service} did not answer on port ${app.PORT} within 90 seconds. Last log lines:\n${await lastLogs(app, { run, systemd, paths })}`);
109
+ }
110
+ return { action, name: app.NAME, service, port: Number(app.PORT), running: true, http, domains };
111
+ }
112
+
113
+ /**
114
+ * Stops the service, removes it from autostart, deletes its unit or init
115
+ * script and its registration. The project folder and its build stay. With
116
+ * the basklee server tool, "basklee app remove" does it and also turns
117
+ * the storefront's domains into a placeholder page.
118
+ */
119
+ async function uninstallService(app, { paths, run, uid, systemd, name, dryRun }) {
120
+ const service = app.SERVICE || `basklee-${app.NAME}`;
121
+ const unitPath = systemd ? join(paths.systemd, `${service}.service`) : join(paths.openrc, service);
122
+ const confPath = join(paths.etc, 'apps', `${app.NAME}.conf`);
123
+ const tool = (paths.tool || []).find(path => existsSync(path));
124
+ const result = { action: 'uninstall', name: app.NAME, service, dir: app.DIR, domains: await frontends(app.DIR), tool: Boolean(tool), unitPath, confPath, dryRun };
125
+ if (dryRun) return result;
126
+ if (uid !== 0) throw new Error(`uninstall needs root: sudo npx basklee-${framework.id} uninstall${name ? ` --name ${name}` : ''}`);
127
+ if (tool) {
128
+ const removed = await run(tool, ['app', 'remove', app.NAME, '--yes']);
129
+ if (removed.code) throw new Error(`basklee app remove ${app.NAME} failed; see the messages above.`);
130
+ return result;
131
+ }
132
+ // A service that is already stopped or missing is fine: the goal is that it is gone.
133
+ if (systemd) await run('systemctl', ['disable', '--now', service], { capture: true });
134
+ else {
135
+ await run('rc-service', [service, 'stop'], { capture: true });
136
+ await run('rc-update', ['del', service, 'default'], { capture: true });
137
+ }
138
+ await rm(unitPath, { force: true });
139
+ if (systemd) await run('systemctl', ['daemon-reload'], { capture: true });
140
+ await rm(confPath, { force: true });
141
+ return result;
142
+ }
143
+
144
+ // The CLI output of controlService; returns the process exit code.
145
+ export function printService(result, log = console.log) {
146
+ const line = item => {
147
+ const state = item.running ? (item.http ? `running, home page HTTP ${item.http}` : 'running, home page does not answer') : 'stopped';
148
+ return `${item.name.padEnd(16)} ${String(item.framework || '').padEnd(7)} ${String(item.port).padEnd(6)} ${state}`;
149
+ };
150
+ if (result.action === 'list') {
151
+ if (!result.apps.length) {
152
+ log(`No storefront services on this server. Install one from its folder: sudo npx basklee-${framework.id} install`);
153
+ return 0;
154
+ }
155
+ log(`${'NAME'.padEnd(16)} ${'TYPE'.padEnd(7)} ${'PORT'.padEnd(6)} STATE`);
156
+ for (const item of result.apps) log(line(item));
157
+ return 0;
158
+ }
159
+ if (result.action === 'status') {
160
+ log(`${result.service} (${result.framework || framework.id}) in ${result.dir}`);
161
+ log(` Service: ${result.running ? 'running' : 'stopped'}${result.enabled ? ', starts with the server' : ', does not start with the server'}`);
162
+ log(` Port: 127.0.0.1:${result.port}`);
163
+ log(` Home page: ${result.running ? (result.http ? `HTTP ${result.http}` : 'does not answer') : '-'}`);
164
+ for (const domain of result.domains) log(` Domain: https://${domain}`);
165
+ return result.running && result.http && result.http < 500 ? 0 : 3;
166
+ }
167
+ if (result.action === 'uninstall') {
168
+ if (result.dryRun) {
169
+ log(`Would stop and remove ${result.service}:`);
170
+ log(result.tool ? ` basklee app remove ${result.name} --yes (also turns its domains into a placeholder)` : ` ${result.unitPath}\n ${result.confPath}`);
171
+ log(`The project stays in ${result.dir}.`);
172
+ return 0;
173
+ }
174
+ log(`Removed the service ${result.service}. The project and its build stay in ${result.dir}; delete the folder when you no longer need it.`);
175
+ if (!result.tool && result.domains.length) {
176
+ log(`nginx still sends ${result.domains.join(', ')} to the stopped service; remove those sites from your nginx configuration.`);
177
+ }
178
+ log(`Install it again with: sudo npx basklee-${framework.id} install`);
179
+ return 0;
180
+ }
181
+ if (result.action === 'stop') log(`Stopped ${result.service}.`);
182
+ else if (result.action === 'start' || result.action === 'restart') {
183
+ log(`${result.action === 'start' ? 'Started' : 'Restarted'} ${result.service}: home page HTTP ${result.http} on 127.0.0.1:${result.port}.`);
184
+ }
185
+ return 0;
186
+ }
package/src/setup.mjs ADDED
@@ -0,0 +1,250 @@
1
+ import { readFile, readdir, lstat, mkdir, writeFile, rename, unlink } from 'node:fs/promises';
2
+ import { resolve, dirname, relative, sep } from 'node:path';
3
+ import { createHash } from 'node:crypto';
4
+ import { parseModule, generateCode } from 'magicast';
5
+ import { backendUrl, frontendDomain } from './validation.mjs';
6
+ import { projectReadme } from './project-readme.mjs';
7
+
8
+ const metadata = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
9
+ const hash = text => createHash('sha256').update(text).digest('hex');
10
+ async function read(path) {
11
+ try { return await readFile(path, 'utf8'); }
12
+ catch (error) { if (error.code === 'ENOENT') return null; throw error; }
13
+ }
14
+ async function safePath(root, name) {
15
+ const target = resolve(root, name);
16
+ if (relative(root, target).startsWith('..') || target === root) throw new Error('Invalid generated path');
17
+ let cursor = root;
18
+ for (const piece of relative(root, target).split(sep)) {
19
+ cursor = resolve(cursor, piece);
20
+ try { if ((await lstat(cursor)).isSymbolicLink()) throw new Error(`Refusing symbolic link: ${name}`); }
21
+ catch (error) { if (error.code !== 'ENOENT') throw error; }
22
+ }
23
+ return target;
24
+ }
25
+ function configureNuxt(source) {
26
+ try {
27
+ const module = parseModule(source);
28
+ const options = module.exports.default.$type === 'function-call'
29
+ ? module.exports.default.$args[0] : module.exports.default;
30
+ if (!options || options.$type !== 'object') throw new Error('Dynamic configuration');
31
+ // Pin the existing Nuxt fallback without changing a customer's chosen date.
32
+ if (options.compatibilityDate === undefined) options.compatibilityDate = '2025-07-15';
33
+ if (options.nitro?.preset && options.nitro.preset !== 'node-server') throw new Error('Unsupported Nitro preset');
34
+ if (options.srcDir || options.serverDir || options.extends) throw new Error('Custom directories or layers');
35
+ for (const route of ['/api', '/api/**', '/api/*']) {
36
+ if (options.routeRules?.[route]?.proxy || options.routeRules?.[route]?.redirect) throw new Error('Conflicting API routing');
37
+ }
38
+ if (options.vite?.server?.proxy?.['/api']) throw new Error('Conflicting Vite proxy');
39
+ options.modules ||= [];
40
+ if (!Array.from(options.modules).some(item => item === '@pinia/nuxt' || (Array.isArray(item) && item[0] === '@pinia/nuxt'))) {
41
+ options.modules.unshift('@pinia/nuxt');
42
+ }
43
+ if (options.pages === false) throw new Error('Route middleware requires Nuxt pages');
44
+ options.pages = true;
45
+ if (!Array.from(options.modules).some(item => item === 'basklee-nuxt' || (Array.isArray(item) && item[0] === 'basklee-nuxt'))) {
46
+ options.modules.push('basklee-nuxt');
47
+ }
48
+ return generateCode(module).code + '\n';
49
+ } catch {
50
+ throw new Error('Cannot safely update this Nuxt configuration. Use a standard Nuxt 4 root config with a literal modules array and no custom srcDir/serverDir, layers, non-Node presets, or /api proxy. No files were changed.');
51
+ }
52
+ }
53
+ function updateEnvironment(source, domain) {
54
+ const lines = (source || '').split(/\r?\n/);
55
+ let updated = false;
56
+ const result = lines.flatMap(line => {
57
+ if (!/^\s*(?:export\s+)?MIMIC_FRONT_DOMAIN\s*=/.test(line)) return [line];
58
+ if (updated) return [];
59
+ updated = true;
60
+ return [`MIMIC_FRONT_DOMAIN="${domain}"`];
61
+ });
62
+ if (!updated) result.push(`MIMIC_FRONT_DOMAIN="${domain}"`);
63
+ return result.join('\n').replace(/^\n/, '').replace(/\n*$/, '\n');
64
+ }
65
+
66
+ export async function setupProject({ cwd = process.cwd(), action = 'set', field, value, dryRun = false } = {}) {
67
+ if (!['set', 'add', 'remove', 'update'].includes(action) ||
68
+ (['add', 'remove'].includes(action) && field !== 'frontend') || (action === 'update' && field)) {
69
+ throw new Error('Use set backend, add frontend, remove frontend, set mimic, or set frontend.');
70
+ }
71
+ const root = resolve(cwd);
72
+ const setting = field === 'backend' ? backendUrl(value) : ['frontend', 'mimic'].includes(field) ? frontendDomain(value) : null;
73
+ if (field && !setting) throw new Error('Choose backend, frontend, or mimic.');
74
+ const names = ['package.json', 'nuxt.config.ts', 'nuxt.config.js', 'nuxt.config.mjs', 'basklee/settings.json', 'basklee/.generated.json', '.env', '.gitignore'];
75
+ const current = {};
76
+ for (const name of names) current[name] = await read(await safePath(root, name));
77
+ const pkg = current['package.json'] ? JSON.parse(current['package.json']) : { name: 'basklee-storefront', private: true, type: 'module' };
78
+ const dependencies = { ...pkg.devDependencies, ...pkg.dependencies };
79
+ for (const name of ['tailwindcss', '@tailwindcss/vite']) {
80
+ if (dependencies[name] && !/^(?:[~^]|>=)?4(?:\.|$)/.test(dependencies[name])) {
81
+ throw new Error(`Basklee components require ${name} 4. Upgrade the existing dependency before setup. No files were changed.`);
82
+ }
83
+ }
84
+ if (action === 'update' && (!dependencies.nuxt || !current['basklee/settings.json'] || !current['basklee/.generated.json'])) {
85
+ throw new Error('Update requires an initialized Basklee Nuxt project. Run init first.');
86
+ }
87
+ if (!dependencies.nuxt && ['next', '@sveltejs/kit'].some(name => dependencies[name])) throw new Error('This package sets up Nuxt projects only.');
88
+ if (dependencies.nuxt && !/^(?:[~^]|>=)?4(?:\.|$)/.test(dependencies.nuxt)) {
89
+ throw new Error('This release supports Nuxt 4. Upgrade your Nuxt dependency before setup.');
90
+ }
91
+ const configs = ['nuxt.config.ts', 'nuxt.config.js', 'nuxt.config.mjs'].filter(name => current[name] !== null);
92
+ if (configs.length > 1) throw new Error('Multiple Nuxt configuration files found; keep one root config.');
93
+ const configName = configs[0] || 'nuxt.config.ts';
94
+ const config = configureNuxt(current[configName] || 'export default defineNuxtConfig({ modules: [] });\n');
95
+ for (const directory of ['server/api', 'server/routes/api']) {
96
+ const path = await safePath(root, directory);
97
+ let entries = [];
98
+ try { entries = await readdir(path); }
99
+ catch (error) { if (error.code !== 'ENOENT') throw error; }
100
+ if (entries.some(name => name.startsWith('[...'))) {
101
+ throw new Error(`Existing API catch-all in ${directory}. Resolve this route conflict first.`);
102
+ }
103
+ }
104
+ const settings = current['basklee/settings.json'] ? JSON.parse(current['basklee/settings.json']) : {};
105
+ const previous = current['basklee/.generated.json'] ? JSON.parse(current['basklee/.generated.json']) : {};
106
+ if (settings.backend) settings.backend = backendUrl(settings.backend);
107
+ if (settings.frontend) settings.frontend = frontendDomain(settings.frontend);
108
+ const oldFrontend = settings.frontend;
109
+ // Migrate the initial single-domain format, including its previously generated mappings.
110
+ const legacyDomains = Object.keys(previous)
111
+ .map(name => /^sitemaps\/([^/]+)\.cfg$/.exec(name)?.[1]).filter(Boolean);
112
+ const frontends = settings.frontends ?? [settings.frontend, ...legacyDomains].filter(Boolean);
113
+ if (!Array.isArray(frontends)) throw new Error('settings.frontends must be an array of domain names.');
114
+ settings.frontends = [...new Set(frontends.map(frontendDomain))];
115
+ if (settings.frontend && !settings.frontends.includes(settings.frontend)) settings.frontends.unshift(settings.frontend);
116
+ if (field === 'backend') settings.backend = setting;
117
+ if (field === 'mimic') {
118
+ if (!settings.frontends.includes(setting)) {
119
+ throw new Error(`Add this frontend before selecting it for MIMIC: ${setting}`);
120
+ }
121
+ settings.frontend = setting;
122
+ }
123
+ if (field === 'frontend') {
124
+ if (action === 'remove') {
125
+ if (!settings.frontends.includes(setting)) throw new Error(`Frontend is not managed by this project: ${setting}`);
126
+ settings.frontends = settings.frontends.filter(domain => domain !== setting);
127
+ if (settings.frontend === setting) settings.frontend = settings.frontends[0];
128
+ } else {
129
+ if (!settings.frontends.includes(setting)) settings.frontends.push(setting);
130
+ // Adding an alias preserves the local development domain. "set" selects it.
131
+ if (action === 'set' || !settings.frontend) settings.frontend = setting;
132
+ }
133
+ }
134
+ settings.frontend ||= settings.frontends[0];
135
+ if (!settings.frontend) delete settings.frontend;
136
+ const manifest = { ...previous };
137
+ const changes = new Map();
138
+ const preserved = [];
139
+ async function plan(name, content, { managed = false, preserve = false } = {}) {
140
+ const path = await safePath(root, name);
141
+ const existing = await read(path);
142
+ if (managed && existing !== null && existing !== content && previous[name] !== hash(existing)) {
143
+ if (preserve && previous[name]) { preserved.push(name); return; }
144
+ throw new Error(`Refusing to overwrite ${name}: it is not an unchanged generated file. No files were changed.`);
145
+ }
146
+ if (existing !== content) changes.set(name, content);
147
+ if (managed) manifest[name] = hash(content);
148
+ }
149
+ async function planRemoval(name) {
150
+ const existing = await read(await safePath(root, name));
151
+ if (existing !== null && previous[name] !== hash(existing)) {
152
+ throw new Error(`Refusing to remove ${name}: it is not an unchanged generated file. No files were changed.`);
153
+ }
154
+ if (existing !== null) changes.set(name, null);
155
+ delete manifest[name];
156
+ }
157
+ // All checks and content generation happen before the first write.
158
+ await plan(configName, config);
159
+ const isNewNuxt = !dependencies.nuxt;
160
+ pkg.scripts ||= {};
161
+ pkg.scripts.dev ||= 'nuxt dev';
162
+ pkg.scripts.build ||= 'nuxt build';
163
+ pkg.scripts.preview ||= 'nuxt preview';
164
+ pkg.scripts['basklee:backend'] ||= 'basklee-nuxt set backend';
165
+ pkg.scripts['basklee:frontend'] ||= 'basklee-nuxt set frontend';
166
+ pkg.scripts['basklee:add-frontend'] ||= 'basklee-nuxt add frontend';
167
+ pkg.scripts['basklee:remove-frontend'] ||= 'basklee-nuxt remove frontend';
168
+ pkg.scripts['basklee:mimic'] ||= 'basklee-nuxt set mimic';
169
+ pkg.scripts['basklee:help'] ||= 'basklee-nuxt help';
170
+ pkg.scripts['basklee:sitemap'] ||= 'basklee-nuxt sitemap rebuild';
171
+ pkg.scripts['basklee:update'] ||= 'basklee-nuxt update';
172
+ pkg.dependencies ||= {};
173
+ pkg.dependencies['libphonenumber-js'] ||= dependencies['libphonenumber-js'] || '^1.13.10';
174
+ pkg.dependencies['country-flag-icons'] ||= dependencies['country-flag-icons'] || '^1.6.20';
175
+ pkg.dependencies.dompurify ||= dependencies.dompurify || '^3.4.13';
176
+ pkg.dependencies.pinia ||= dependencies.pinia || '^4.0.2';
177
+ pkg.dependencies['@pinia/nuxt'] ||= dependencies['@pinia/nuxt'] || '^1.0.1';
178
+ pkg.dependencies['basklee-nuxt'] ||= dependencies['basklee-nuxt'] || `^${metadata.version}`;
179
+ if (action === 'update') {
180
+ pkg.dependencies['basklee-nuxt'] = metadata.version;
181
+ if (pkg.devDependencies) delete pkg.devDependencies['basklee-nuxt'];
182
+ }
183
+ if (isNewNuxt) {
184
+ pkg.dependencies.nuxt = '^4.5.0';
185
+ pkg.dependencies.vue ||= '^3.5.0';
186
+ pkg.dependencies['vue-router'] ||= '^5.0.0';
187
+ }
188
+ // Install the complete editable AppLoad source. Never replace a customer's app.
189
+ const appPath = 'app/app.vue';
190
+ const existingApp = await read(await safePath(root, appPath));
191
+ const installApp = existingApp === null || Boolean(previous[appPath]);
192
+ const templateRoot = new URL('../templates/', import.meta.url);
193
+ async function planTemplates(directory = '') {
194
+ for (const entry of await readdir(new URL(directory, templateRoot), { withFileTypes: true })) {
195
+ const name = directory + entry.name;
196
+ if (entry.isDirectory()) { await planTemplates(name + '/'); continue; }
197
+ if (name === appPath && !installApp) continue;
198
+ // A customer's own home page and editor settings stay theirs.
199
+ if (['app/pages/index.vue', '.vscode/settings.json'].includes(name) && !previous[name] && await read(await safePath(root, name)) !== null) continue;
200
+ await plan(name, await readFile(new URL(name, templateRoot), 'utf8'), { managed: true, preserve: true });
201
+ }
202
+ }
203
+ await planTemplates();
204
+ pkg.devDependencies ||= {};
205
+ for (const name of ['tailwindcss', '@tailwindcss/vite']) {
206
+ if (!dependencies[name]) pkg.devDependencies[name] = '^4.3.3';
207
+ }
208
+ if (!await read(await safePath(root, 'tsconfig.json'))) {
209
+ await plan('tsconfig.json', JSON.stringify({ files: [], references: [
210
+ { path: './.nuxt/tsconfig.app.json' }, { path: './.nuxt/tsconfig.server.json' },
211
+ { path: './.nuxt/tsconfig.shared.json' }, { path: './.nuxt/tsconfig.node.json' },
212
+ ] }, null, 2) + '\n', { managed: true });
213
+ }
214
+ await plan('package.json', JSON.stringify(pkg, null, 2) + '\n');
215
+ for (const file of ['marketplace.mjs', 'api.mjs', 'domain.mjs', 'seo.mjs']) {
216
+ await plan(`basklee/runtime/${file}`, await readFile(new URL(`../runtime/${file}`, import.meta.url), 'utf8'), { managed: true, preserve: true });
217
+ }
218
+ await plan('basklee/README.md', projectReadme(settings), { managed: true, preserve: true });
219
+ // A new project starts explicitly empty; keep a pre-existing manual setting on init.
220
+ const hasMimicSetting = /^\s*(?:export\s+)?MIMIC_FRONT_DOMAIN\s*=/m.test(current['.env'] || '');
221
+ if (action !== 'update' && (settings.frontend || oldFrontend || !hasMimicSetting)) {
222
+ await plan('.env', updateEnvironment(current['.env'], settings.frontend || ''));
223
+ }
224
+ if (settings.backend && action !== 'update') {
225
+ const mappings = action === 'remove' || field === 'mimic' ? []
226
+ : field === 'frontend' ? [setting] : settings.frontends;
227
+ for (const domain of mappings) {
228
+ await plan(`sitemaps/${domain}.cfg`, settings.backend + '\n', { managed: true });
229
+ }
230
+ }
231
+ if (action === 'remove') await planRemoval(`sitemaps/${setting}.cfg`);
232
+ let ignore = current['.gitignore'] || '';
233
+ for (const entry of ['node_modules/', '.nuxt/', '.output/', '.env', '.env.*', '!.env.example']) {
234
+ if (!ignore.split(/\r?\n/).includes(entry)) ignore = ignore.replace(/\n*$/, '\n') + entry + '\n';
235
+ }
236
+ await plan('.gitignore', ignore);
237
+ if (action !== 'update') await plan('basklee/settings.json', JSON.stringify(settings, null, 2) + '\n');
238
+ await plan('basklee/.generated.json', JSON.stringify(manifest, null, 2) + '\n');
239
+ if (!dryRun) {
240
+ for (const [name, content] of changes) {
241
+ const target = await safePath(root, name);
242
+ if (content === null) { await unlink(target); continue; }
243
+ await mkdir(dirname(target), { recursive: true });
244
+ const temporary = `${target}.basklee-${process.pid}.tmp`;
245
+ await writeFile(temporary, content, { mode: name === '.env' ? 0o600 : 0o644, flag: 'wx' });
246
+ await rename(temporary, target);
247
+ }
248
+ }
249
+ return { root, settings, changed: [...changes.keys()], removed: [...changes].filter(([, content]) => content === null).map(([name]) => name), preserved, dryRun, isNewNuxt };
250
+ }
@@ -0,0 +1,93 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { readFile } from 'node:fs/promises';
3
+ import { relative, resolve } from 'node:path';
4
+ import { pathToFileURL } from 'node:url';
5
+
6
+ const metadata = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
7
+ const cli = metadata.name;
8
+
9
+ /**
10
+ * The project's own gateway runtime (basklee/runtime/marketplace.mjs): the
11
+ * sitemap is built with the code the running storefront uses.
12
+ */
13
+ async function projectRuntime(root) {
14
+ const path = resolve(root, 'basklee/runtime/marketplace.mjs');
15
+ if (!existsSync(path)) {
16
+ throw new Error(`No basklee/runtime/marketplace.mjs in ${root}. Run this in the storefront project (or pass --cwd).`);
17
+ }
18
+ const runtime = await import(pathToFileURL(path).href);
19
+ if (typeof runtime.rebuildMarketplaceSitemap !== 'function') {
20
+ throw new Error(`This project's runtime has no sitemap support. Run npx ${cli} update first.`);
21
+ }
22
+ return runtime;
23
+ }
24
+
25
+ /**
26
+ * The storefront reads SITEMAPS_DIR and BASKLEE_CACHE_DIR from the
27
+ * project's .env; the command uses the same folders. Variables already set
28
+ * in the shell win.
29
+ */
30
+ async function projectEnvironment(root) {
31
+ let source = '';
32
+ try { source = await readFile(resolve(root, '.env'), 'utf8'); }
33
+ catch (error) { if (error.code !== 'ENOENT') throw error; }
34
+ for (const line of source.split(/\r?\n/)) {
35
+ const match = /^\s*(?:export\s+)?(SITEMAPS_DIR|BASKLEE_CACHE_DIR)\s*=\s*(.*?)\s*$/.exec(line);
36
+ if (!match || process.env[match[1]] !== undefined) continue;
37
+ const value = match[2].replace(/^(['"])(.*)\1$/, '$2');
38
+ if (value) process.env[match[1]] = resolve(root, value);
39
+ }
40
+ }
41
+
42
+ async function domainsFor(runtime, root, domain) {
43
+ if (domain) {
44
+ const normalized = runtime.normalizeFrontDomain(domain);
45
+ if (!normalized) throw new Error(`Invalid frontend domain: ${domain}`);
46
+ return [normalized];
47
+ }
48
+ const domains = await runtime.marketplaceDomains(root);
49
+ if (!domains.length) throw new Error(`No frontend domains yet. Add one: npx ${cli} add frontend <shop.example.com>`);
50
+ return domains;
51
+ }
52
+
53
+ function age(built, now = Date.now()) {
54
+ const minutes = Math.max(0, Math.round((now - Date.parse(built)) / 60_000));
55
+ return minutes < 60 ? `${minutes} min ago` : `${Math.floor(minutes / 60)} h ${minutes % 60} min ago`;
56
+ }
57
+
58
+ /**
59
+ * `sitemap rebuild [domain]`: build the sitemap of every frontend domain (or
60
+ * one) now. `sitemap status [domain]`: show when each was built.
61
+ * @param {{cwd: string, action: string, domain?: string, log?: (line: string) => void}} options
62
+ * @returns {Promise<number>} exit code
63
+ */
64
+ export async function sitemapCommand({ cwd, action, domain, log = console.log }) {
65
+ if (!['rebuild', 'status'].includes(action)) {
66
+ throw new Error(`Use: npx ${cli} sitemap rebuild [domain] | sitemap status [domain]`);
67
+ }
68
+ const root = resolve(cwd);
69
+ await projectEnvironment(root);
70
+ const runtime = await projectRuntime(root);
71
+ const domains = await domainsFor(runtime, root, domain);
72
+ let failed = 0;
73
+ for (const name of domains) {
74
+ if (action === 'status') {
75
+ const sitemap = await runtime.readSitemapCache(name, root);
76
+ const stale = sitemap && Date.now() - Date.parse(sitemap.built) >= runtime.SITEMAP_LIFETIME;
77
+ log(sitemap
78
+ ? `${name}: built ${sitemap.built} (${age(sitemap.built)}), ${runtime.sitemapUrlCount(sitemap)} URLs${stale ? '; rebuilt at the next crawl' : ''}`
79
+ : `${name}: not built yet; built at the first /sitemap.xml request or with: npx ${cli} sitemap rebuild`);
80
+ continue;
81
+ }
82
+ const started = Date.now();
83
+ try {
84
+ const done = await runtime.rebuildMarketplaceSitemap(name, { root });
85
+ log(`${name}: ${done.urls} URLs (${done.pages} pages, ${done.publications} journal publications) in ${((Date.now() - started) / 1000).toFixed(1)} s`);
86
+ log(` saved ${relative(root, done.path)}; the running storefront serves it now at https://${name}/sitemap.xml`);
87
+ } catch (error) {
88
+ failed++;
89
+ log(`${name}: not rebuilt: ${error?.message ?? error}`);
90
+ }
91
+ }
92
+ return failed ? 1 : 0;
93
+ }
package/src/update.mjs ADDED
@@ -0,0 +1,54 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { readFileSync } from 'node:fs';
3
+ import { resolve } from 'node:path';
4
+ import { migrateLegacyProject } from './migrate.mjs';
5
+ import { setupProject } from './setup.mjs';
6
+
7
+ const PACKAGE = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
8
+
9
+ function printMigration(done, dryRun) {
10
+ console.log(`${dryRun ? 'Would rename' : 'Renamed'} this project from the old orionplace names to Basklee (${done.files.length} files changed, ${done.moved} moved; dependency ${done.dependency}).`);
11
+ if (done.backup) console.log(`Backup of every changed file, at its old path: ${done.backup}/ (delete it after checking).`);
12
+ }
13
+
14
+ export function runNpm(args, cwd) {
15
+ const npmCli = process.env.npm_execpath;
16
+ const command = npmCli ? process.execPath : 'npm';
17
+ const commandArgs = npmCli ? [npmCli, ...args] : args;
18
+ return new Promise((resolve, reject) => {
19
+ const child = spawn(command, commandArgs, { cwd, stdio: 'inherit', shell: false });
20
+ child.once('error', reject);
21
+ child.once('exit', (code, signal) => code === 0 ? resolve() : reject(new Error(
22
+ `npm ${args[0]} failed (${signal || code}).`,
23
+ )));
24
+ });
25
+ }
26
+
27
+ export async function updateProject({ cwd = process.cwd(), dryRun = false, local = false, npm = runNpm } = {}) {
28
+ cwd = resolve(cwd);
29
+ // A project made before the rename to Basklee is renamed first (migrate.mjs); the latest CLI does it.
30
+ const legacy = await migrateLegacyProject({ cwd, dryRun: true, packageName: PACKAGE.name, version: PACKAGE.version });
31
+ // Validate before downloading or writing; the latest CLI repeats preflight with its own templates.
32
+ const preview = legacy ? null : await setupProject({ cwd, action: 'update', dryRun: true });
33
+ if (!local) {
34
+ console.log('Checking the latest Basklee Nuxt release…');
35
+ await npm(['exec', '--yes', '--prefer-online', '--package=basklee-nuxt@latest', '--',
36
+ 'basklee-nuxt', 'update', '--local', '--cwd', cwd, ...(dryRun ? ['--dry-run'] : [])], cwd);
37
+ return null; // The latest CLI reports its own changes.
38
+ }
39
+ if (legacy && dryRun) {
40
+ printMigration(legacy, true);
41
+ for (const file of legacy.files) console.log(` ${file}`);
42
+ console.log('The template update is planned after the rename: run update without --dry-run, then update --dry-run again.');
43
+ return null;
44
+ }
45
+ if (dryRun) return preview;
46
+ if (legacy) printMigration(await migrateLegacyProject({ cwd, packageName: PACKAGE.name, version: PACKAGE.version }), false);
47
+ const result = await setupProject({ cwd, action: 'update' });
48
+ try {
49
+ await npm(['install', '--no-audit', '--no-fund'], cwd);
50
+ } catch (error) {
51
+ throw new Error(`Source files were updated, but dependency installation failed. Run npm install in the project, then retry update. ${error.message}`);
52
+ }
53
+ return result;
54
+ }
@@ -0,0 +1,33 @@
1
+ import { isIP } from 'node:net';
2
+ const dns = /^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
3
+
4
+ export function frontendDomain(value) {
5
+ let url;
6
+ try { url = new URL(value.includes('://') ? value : `https://${value}`); }
7
+ catch { throw new Error('Use a public frontend hostname, for example shop.example.com.'); }
8
+ const domain = url.hostname.toLowerCase().replace(/\.$/, '');
9
+ if (!dns.test(domain) || isIP(domain) || url.username || url.password || url.port ||
10
+ url.search || url.hash || url.pathname !== '/' || !['http:', 'https:'].includes(url.protocol)) {
11
+ throw new Error('Frontend must be a public hostname without a port, path, or credentials.');
12
+ }
13
+ return domain;
14
+ }
15
+
16
+ export function backendUrl(value) {
17
+ let url;
18
+ try { url = new URL(value.includes('://') ? value : `https://${value}`); }
19
+ catch { throw new Error('Use the personal backend domain shown in your Basklee account.'); }
20
+ const path = url.pathname.replace(/\/+$/, '');
21
+ if (url.protocol !== 'https:' || !dns.test(url.hostname) ||
22
+ !url.hostname.endsWith('.orionplace.app') || url.username || url.password ||
23
+ url.port || url.search || url.hash || !['', '/api'].includes(path)) {
24
+ throw new Error('Backend must be https://<your-project>.orionplace.app or its /api URL.');
25
+ }
26
+ return `${url.origin}/api`;
27
+ }
28
+
29
+ // The Android app sends its API requests to this public storefront over HTTPS.
30
+ export function appOrigin(value) {
31
+ if (/^\s*http:/i.test(value)) throw new Error('BASKLEE_APP_ORIGIN must use HTTPS.');
32
+ return `https://${frontendDomain(value.trim())}`;
33
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ // The storefront styles use Tailwind's @apply, @reference and @theme, which
3
+ // the editor's CSS checker does not know; the build handles them.
4
+ "css.lint.unknownAtRules": "ignore"
5
+ }