@upstart.gg/sdk 0.0.96 → 0.0.98
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.
- package/dist/node/cli/api.js +2 -2
- package/dist/node/cli/api.js.map +1 -1
- package/dist/node/cli/commands/login/cmd-login.js +6 -6
- package/dist/node/cli/commands/login/cmd-login.js.map +1 -1
- package/dist/node/cli/commands/publish/cmd-publish.d.ts.map +1 -1
- package/dist/node/cli/commands/publish/cmd-publish.js +18 -18
- package/dist/node/cli/commands/publish/cmd-publish.js.map +1 -1
- package/dist/node/cli/commands/publish/uploader.js +7 -7
- package/dist/node/cli/commands/publish/uploader.js.map +1 -1
- package/dist/node/cli/is-logged-in.js +2 -2
- package/dist/node/cli/is-logged-in.js.map +1 -1
- package/dist/node/cli/program.js +24 -24
- package/dist/node/cli/program.js.map +1 -1
- package/dist/node/shared/config.d.ts +4 -14
- package/dist/node/shared/config.d.ts.map +1 -1
- package/dist/node/shared/config.js +4 -4
- package/dist/node/shared/config.js.map +1 -1
- package/dist/node/shared/logger.d.ts.map +1 -1
- package/dist/node/shared/logger.js +2 -2
- package/dist/node/shared/logger.js.map +1 -1
- package/dist/shared/ajv.d.ts +2 -0
- package/dist/shared/ajv.d.ts.map +1 -1
- package/dist/shared/ajv.js +1 -1
- package/dist/shared/attributes.d.ts +20 -93
- package/dist/shared/attributes.d.ts.map +1 -1
- package/dist/shared/attributes.js +1 -1
- package/dist/shared/brick-manifest.d.ts +7 -17
- package/dist/shared/brick-manifest.d.ts.map +1 -1
- package/dist/shared/brick-manifest.js +1 -1
- package/dist/shared/bricks/manifests/accordion.manifest.d.ts +111 -0
- package/dist/shared/bricks/manifests/accordion.manifest.d.ts.map +1 -0
- package/dist/shared/bricks/manifests/accordion.manifest.js +3 -0
- package/dist/shared/bricks/manifests/all-manifests.d.ts +5 -0
- package/dist/shared/bricks/manifests/all-manifests.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/all-manifests.js +1 -1
- package/dist/shared/bricks/manifests/button.manifest.d.ts +22 -13
- package/dist/shared/bricks/manifests/button.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/button.manifest.js +1 -1
- package/dist/shared/bricks/manifests/card.manifest.d.ts +44 -54
- package/dist/shared/bricks/manifests/card.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/card.manifest.js +1 -1
- package/dist/shared/bricks/manifests/carousel.manifest.d.ts +39 -12
- package/dist/shared/bricks/manifests/carousel.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/carousel.manifest.js +1 -1
- package/dist/shared/bricks/manifests/container.manifest.d.ts +49 -172
- package/dist/shared/bricks/manifests/container.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/container.manifest.js +1 -1
- package/dist/shared/bricks/manifests/divider.manifest.d.ts +63 -0
- package/dist/shared/bricks/manifests/divider.manifest.d.ts.map +1 -0
- package/dist/shared/bricks/manifests/divider.manifest.js +3 -0
- package/dist/shared/bricks/manifests/footer.manifest.d.ts +30 -35
- package/dist/shared/bricks/manifests/footer.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/footer.manifest.js +1 -1
- package/dist/shared/bricks/manifests/form.manifest.d.ts +22 -12
- package/dist/shared/bricks/manifests/form.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/form.manifest.js +1 -1
- package/dist/shared/bricks/manifests/hero.manifest.d.ts +31 -71
- package/dist/shared/bricks/manifests/hero.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/hero.manifest.js +1 -1
- package/dist/shared/bricks/manifests/icon.manifest.d.ts +18 -12
- package/dist/shared/bricks/manifests/icon.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/icon.manifest.js +1 -1
- package/dist/shared/bricks/manifests/image.manifest.d.ts +36 -50
- package/dist/shared/bricks/manifests/image.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/image.manifest.js +1 -1
- package/dist/shared/bricks/manifests/images-gallery.manifest.d.ts +55 -115
- package/dist/shared/bricks/manifests/images-gallery.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/images-gallery.manifest.js +1 -1
- package/dist/shared/bricks/manifests/map.manifest.d.ts +36 -12
- package/dist/shared/bricks/manifests/map.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/map.manifest.js +1 -1
- package/dist/shared/bricks/manifests/navbar.manifest.d.ts +160 -0
- package/dist/shared/bricks/manifests/navbar.manifest.d.ts.map +1 -0
- package/dist/shared/bricks/manifests/navbar.manifest.js +3 -0
- package/dist/shared/bricks/manifests/sidebar.manifest.d.ts +83 -12
- package/dist/shared/bricks/manifests/sidebar.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/sidebar.manifest.js +1 -1
- package/dist/shared/bricks/manifests/social-links.manifest.d.ts +37 -12
- package/dist/shared/bricks/manifests/social-links.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/social-links.manifest.js +1 -1
- package/dist/shared/bricks/manifests/testimonials.manifest.d.ts +94 -0
- package/dist/shared/bricks/manifests/testimonials.manifest.d.ts.map +1 -0
- package/dist/shared/bricks/manifests/testimonials.manifest.js +3 -0
- package/dist/shared/bricks/manifests/text.manifest.d.ts +31 -63
- package/dist/shared/bricks/manifests/text.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/text.manifest.js +1 -1
- package/dist/shared/bricks/manifests/timeline.manifest.d.ts +122 -0
- package/dist/shared/bricks/manifests/timeline.manifest.d.ts.map +1 -0
- package/dist/shared/bricks/manifests/timeline.manifest.js +3 -0
- package/dist/shared/bricks/manifests/video.manifest.d.ts +38 -12
- package/dist/shared/bricks/manifests/video.manifest.d.ts.map +1 -1
- package/dist/shared/bricks/manifests/video.manifest.js +1 -1
- package/dist/shared/bricks/props/_style-presets.d.ts +1 -1
- package/dist/shared/bricks/props/_style-presets.d.ts.map +1 -1
- package/dist/shared/bricks/props/_style-presets.js +1 -1
- package/dist/shared/bricks/props/align.d.ts +7 -3
- package/dist/shared/bricks/props/align.d.ts.map +1 -1
- package/dist/shared/bricks/props/align.js +1 -1
- package/dist/shared/bricks/props/background.d.ts +8 -1
- package/dist/shared/bricks/props/background.d.ts.map +1 -1
- package/dist/shared/bricks/props/background.js +1 -1
- package/dist/shared/bricks/props/boolean.js +1 -1
- package/dist/shared/bricks/props/border.d.ts +24 -22
- package/dist/shared/bricks/props/border.d.ts.map +1 -1
- package/dist/shared/bricks/props/border.js +1 -1
- package/dist/shared/bricks/props/color.d.ts +5 -0
- package/dist/shared/bricks/props/color.d.ts.map +1 -0
- package/dist/shared/bricks/props/color.js +3 -0
- package/dist/shared/bricks/props/common.d.ts +9 -1
- package/dist/shared/bricks/props/common.d.ts.map +1 -1
- package/dist/shared/bricks/props/common.js +1 -1
- package/dist/shared/bricks/props/container.d.ts +37 -45
- package/dist/shared/bricks/props/container.d.ts.map +1 -1
- package/dist/shared/bricks/props/container.js +1 -1
- package/dist/shared/bricks/props/css-length.d.ts +5 -0
- package/dist/shared/bricks/props/css-length.d.ts.map +1 -0
- package/dist/shared/bricks/props/css-length.js +3 -0
- package/dist/shared/bricks/props/datasource.d.ts +9 -13
- package/dist/shared/bricks/props/datasource.d.ts.map +1 -1
- package/dist/shared/bricks/props/datasource.js +1 -1
- package/dist/shared/bricks/props/date.d.ts +4 -0
- package/dist/shared/bricks/props/date.d.ts.map +1 -0
- package/dist/shared/bricks/props/date.js +3 -0
- package/dist/shared/bricks/props/effects.d.ts +4 -21
- package/dist/shared/bricks/props/effects.d.ts.map +1 -1
- package/dist/shared/bricks/props/effects.js +1 -1
- package/dist/shared/bricks/props/enum.d.ts +13 -0
- package/dist/shared/bricks/props/enum.d.ts.map +1 -0
- package/dist/shared/bricks/props/enum.js +3 -0
- package/dist/shared/bricks/props/file.d.ts +2 -0
- package/dist/shared/bricks/props/file.d.ts.map +1 -0
- package/dist/shared/bricks/props/file.js +3 -0
- package/dist/shared/bricks/props/geolocation.d.ts +16 -0
- package/dist/shared/bricks/props/geolocation.d.ts.map +1 -0
- package/dist/shared/bricks/props/geolocation.js +3 -0
- package/dist/shared/bricks/props/helpers.d.ts +8 -4
- package/dist/shared/bricks/props/helpers.d.ts.map +1 -1
- package/dist/shared/bricks/props/helpers.js +1 -1
- package/dist/shared/bricks/props/image.d.ts +7 -1
- package/dist/shared/bricks/props/image.d.ts.map +1 -1
- package/dist/shared/bricks/props/image.js +1 -1
- package/dist/shared/bricks/props/number.js +1 -1
- package/dist/shared/bricks/props/padding.d.ts +2 -1
- package/dist/shared/bricks/props/padding.d.ts.map +1 -1
- package/dist/shared/bricks/props/padding.js +1 -1
- package/dist/shared/bricks/props/position.d.ts.map +1 -1
- package/dist/shared/bricks/props/position.js +1 -1
- package/dist/shared/bricks/props/preset.d.ts +92 -0
- package/dist/shared/bricks/props/preset.d.ts.map +1 -0
- package/dist/shared/bricks/props/preset.js +3 -0
- package/dist/shared/bricks/props/string.d.ts +8 -3
- package/dist/shared/bricks/props/string.d.ts.map +1 -1
- package/dist/shared/bricks/props/string.js +1 -1
- package/dist/shared/bricks/props/text.d.ts +3 -4
- package/dist/shared/bricks/props/text.d.ts.map +1 -1
- package/dist/shared/bricks/props/text.js +1 -1
- package/dist/shared/bricks/props/types.d.ts +5 -2
- package/dist/shared/bricks/props/types.d.ts.map +1 -1
- package/dist/shared/bricks.d.ts +243 -134
- package/dist/shared/bricks.d.ts.map +1 -1
- package/dist/shared/bricks.js +1 -1
- package/dist/shared/chunk-2AJYHJFG.js +8 -0
- package/dist/shared/chunk-2HS6NFHZ.js +3 -0
- package/dist/shared/chunk-3LMJVUDG.js +7 -0
- package/dist/shared/chunk-3VZACK2Y.js +3 -0
- package/dist/shared/chunk-3XCKZ4JQ.js +3 -0
- package/dist/shared/chunk-6ALXIMUO.js +3 -0
- package/dist/shared/chunk-6VX2WGTP.js +3 -0
- package/dist/shared/chunk-74EL657O.js +3 -0
- package/dist/shared/chunk-AJDYOLKP.js +3 -0
- package/dist/shared/chunk-AKBI3X4Q.js +3 -0
- package/dist/shared/chunk-ALFOZHAH.js +3 -0
- package/dist/shared/{chunk-FGU4BGP4.js → chunk-ATDJCXC2.js} +1 -1
- package/dist/shared/chunk-AZOGBANS.js +3 -0
- package/dist/shared/chunk-BJSO43AS.js +3 -0
- package/dist/shared/chunk-CAVNF3BU.js +3 -0
- package/dist/shared/chunk-CT4RLIMR.js +6 -0
- package/dist/shared/chunk-CTRS76PX.js +3 -0
- package/dist/shared/chunk-DFSQR6QC.js +3 -0
- package/dist/shared/chunk-ECNYDOAO.js +3 -0
- package/dist/shared/chunk-FHOCVBK6.js +3 -0
- package/dist/shared/chunk-G7LX3UKQ.js +3 -0
- package/dist/shared/chunk-HYVQXAK5.js +3 -0
- package/dist/shared/chunk-I4P4RZXY.js +4 -0
- package/dist/shared/chunk-IIEPRDBY.js +3 -0
- package/dist/shared/chunk-JQXWLMDD.js +8 -0
- package/dist/shared/chunk-KKER3X7F.js +6 -0
- package/dist/shared/chunk-KPYTQFWJ.js +3 -0
- package/dist/shared/chunk-KUGWXEBW.js +3 -0
- package/dist/shared/chunk-KWR57RUG.js +3 -0
- package/dist/shared/chunk-LKVQQQTI.js +3 -0
- package/dist/shared/chunk-MYI3IN5Z.js +3 -0
- package/dist/shared/chunk-NNO3S4VF.js +3 -0
- package/dist/shared/chunk-OUI2VDNM.js +3 -0
- package/dist/shared/chunk-OYIL5SCU.js +3 -0
- package/dist/shared/chunk-P5DZK4TS.js +3 -0
- package/dist/shared/chunk-Q3U4SRIF.js +3 -0
- package/dist/shared/chunk-Q74LWG7R.js +3 -0
- package/dist/shared/chunk-RBLZ3RK4.js +3 -0
- package/dist/shared/chunk-U5AQVZF6.js +3 -0
- package/dist/shared/chunk-U5XOIYSS.js +3 -0
- package/dist/shared/chunk-UBOQDP6V.js +5 -0
- package/dist/shared/chunk-UDQJDXVN.js +3 -0
- package/dist/shared/{chunk-HIZPJNEM.js → chunk-UL7L3HYV.js} +1 -1
- package/dist/shared/chunk-V5ZYAZ7J.js +3 -0
- package/dist/shared/chunk-VA5LFJVE.js +3 -0
- package/dist/shared/chunk-VAC73HJE.js +3 -0
- package/dist/shared/chunk-VBWC36L2.js +3 -0
- package/dist/shared/chunk-VTFWVTPI.js +3 -0
- package/dist/shared/chunk-WAAKB6OB.js +3 -0
- package/dist/shared/chunk-Y27LBC4Q.js +3 -0
- package/dist/shared/chunk-Y7CEEEVW.js +3 -0
- package/dist/shared/chunk-YZ5Y4WE6.js +3 -0
- package/dist/shared/chunk-ZJNA4QQC.js +3 -0
- package/dist/shared/chunk-ZMDHKAWL.js +3 -0
- package/dist/shared/context.d.ts +38 -0
- package/dist/shared/context.d.ts.map +1 -0
- package/dist/shared/{chunk-WJ5CDDXW.js → context.js} +0 -1
- package/dist/shared/datarecords/types.d.ts +40 -20
- package/dist/shared/datarecords/types.d.ts.map +1 -1
- package/dist/shared/datarecords/types.js +1 -1
- package/dist/shared/datasources/external/facebook/posts/fetcher.d.ts.map +1 -1
- package/dist/shared/datasources/external/http-json/fetcher.d.ts.map +1 -0
- package/dist/shared/datasources/external/http-json/options.d.ts.map +1 -0
- package/dist/shared/datasources/external/{json → http-json}/schema.d.ts +0 -1
- package/dist/shared/datasources/external/http-json/schema.d.ts.map +1 -0
- package/dist/shared/datasources/external/http-json/tests/fetcher.test.d.ts.map +1 -0
- package/dist/shared/datasources/external/instagram/feed/fetcher.d.ts.map +1 -1
- package/dist/shared/datasources/external/mastodon/account/fetcher.d.ts.map +1 -1
- package/dist/shared/datasources/external/mastodon/status/fetcher.d.ts.map +1 -1
- package/dist/shared/datasources/external/rss/fetcher.d.ts.map +1 -1
- package/dist/shared/datasources/external/rss/sample.d.ts.map +1 -1
- package/dist/shared/datasources/external/rss/schema.d.ts +7 -13
- package/dist/shared/datasources/external/rss/schema.d.ts.map +1 -1
- package/dist/shared/datasources/external/threads/media/fetcher.d.ts.map +1 -1
- package/dist/shared/datasources/external/tiktok/video/fetcher.d.ts.map +1 -1
- package/dist/shared/datasources/external/youtube/list/fetcher.d.ts.map +1 -1
- package/dist/shared/datasources/external/youtube/list/sample.d.ts +23 -32
- package/dist/shared/datasources/external/youtube/list/sample.d.ts.map +1 -1
- package/dist/shared/datasources/external/youtube/list/schema.d.ts +24 -33
- package/dist/shared/datasources/external/youtube/list/schema.d.ts.map +1 -1
- package/dist/shared/datasources/internal/blog/schema.d.ts.map +1 -1
- package/dist/shared/datasources/internal/changelog/schema.d.ts.map +1 -1
- package/dist/shared/datasources/internal/recipes/schema.d.ts.map +1 -1
- package/dist/shared/datasources/samples.d.ts +1 -1
- package/dist/shared/datasources/samples.d.ts.map +1 -1
- package/dist/shared/datasources/schemas.d.ts +33 -583
- package/dist/shared/datasources/schemas.d.ts.map +1 -1
- package/dist/shared/datasources/schemas.js +1 -1
- package/dist/shared/datasources/types.d.ts +75 -1314
- package/dist/shared/datasources/types.d.ts.map +1 -1
- package/dist/shared/datasources/types.js +1 -1
- package/dist/shared/datasources.d.ts +14 -0
- package/dist/shared/datasources.d.ts.map +1 -1
- package/dist/shared/datasources.js +1 -1
- package/dist/shared/images.d.ts +30 -0
- package/dist/shared/images.d.ts.map +1 -0
- package/dist/shared/images.js +3 -0
- package/dist/shared/layout-constants.js +1 -1
- package/dist/shared/page.d.ts +104 -2670
- package/dist/shared/page.d.ts.map +1 -1
- package/dist/shared/page.js +1 -1
- package/dist/shared/prompt.d.ts +4 -0
- package/dist/shared/prompt.d.ts.map +1 -0
- package/dist/shared/prompt.js +3 -0
- package/dist/shared/responsive.d.ts +3 -3
- package/dist/shared/responsive.d.ts.map +1 -1
- package/dist/shared/responsive.js +1 -1
- package/dist/shared/site.d.ts +545 -0
- package/dist/shared/site.d.ts.map +1 -0
- package/dist/shared/site.js +3 -0
- package/dist/shared/sitemap.d.ts +38 -0
- package/dist/shared/sitemap.d.ts.map +1 -0
- package/dist/shared/sitemap.js +3 -0
- package/dist/shared/theme.d.ts +41 -19
- package/dist/shared/theme.d.ts.map +1 -1
- package/dist/shared/theme.js +1 -1
- package/dist/shared/themes/color-system.d.ts +5 -309
- package/dist/shared/themes/color-system.d.ts.map +1 -1
- package/dist/shared/themes/color-system.js +1 -1
- package/dist/shared/utils/invariant.js +1 -1
- package/dist/shared/utils/schema.d.ts +10 -2
- package/dist/shared/utils/schema.d.ts.map +1 -1
- package/dist/shared/utils/schema.js +1 -1
- package/dist/shared/utils/typed-ref.d.ts +32 -0
- package/dist/shared/utils/typed-ref.d.ts.map +1 -0
- package/dist/shared/utils/typed-ref.js +3 -0
- package/package.json +11 -11
- package/src/node/cli/api.ts +101 -0
- package/src/node/cli/commands/cmd-build.ts +64 -0
- package/src/node/cli/commands/login/cmd-login.ts +111 -0
- package/src/node/cli/commands/logout/cmd-logout.ts +11 -0
- package/src/node/cli/commands/publish/cmd-publish.ts +135 -0
- package/src/node/cli/commands/publish/parse-gitignore.ts +278 -0
- package/src/node/cli/commands/publish/uploader.ts +333 -0
- package/src/node/cli/constants.ts +14 -0
- package/src/node/cli/is-logged-in.ts +28 -0
- package/src/node/cli/program.ts +77 -0
- package/src/node/cli/store.ts +64 -0
- package/src/node/cli/tests/api.test.ts +161 -0
- package/src/node/cli/types.ts +34 -0
- package/src/node/cli/utils.ts +20 -0
- package/src/node/shared/config.ts +69 -0
- package/src/node/shared/logger.ts +44 -0
- package/src/shared/ajv.ts +110 -0
- package/src/shared/analytics/init.ts +14 -0
- package/src/shared/analytics/track.ts +21 -0
- package/src/shared/analytics/types.ts +13 -0
- package/src/shared/attributes.ts +221 -0
- package/src/shared/brick-manifest.ts +110 -0
- package/src/shared/bricks/manifests/accordion.manifest.ts +179 -0
- package/src/shared/bricks/manifests/all-manifests.ts +92 -0
- package/src/shared/bricks/manifests/button.manifest.ts +145 -0
- package/src/shared/bricks/manifests/card.manifest.ts +269 -0
- package/src/shared/bricks/manifests/carousel.manifest.ts +106 -0
- package/src/shared/bricks/manifests/container.manifest.ts +357 -0
- package/src/shared/bricks/manifests/divider.manifest.ts +121 -0
- package/src/shared/bricks/manifests/footer.manifest.ts +487 -0
- package/src/shared/bricks/manifests/form.manifest.ts +112 -0
- package/src/shared/bricks/manifests/hero.manifest.ts +132 -0
- package/src/shared/bricks/manifests/icon.manifest.ts +130 -0
- package/src/shared/bricks/manifests/image.manifest.ts +203 -0
- package/src/shared/bricks/manifests/images-gallery.manifest.ts +227 -0
- package/src/shared/bricks/manifests/map.manifest.ts +75 -0
- package/src/shared/bricks/manifests/navbar.manifest.ts +344 -0
- package/src/shared/bricks/manifests/sidebar.manifest.ts +90 -0
- package/src/shared/bricks/manifests/social-links.manifest.ts +370 -0
- package/src/shared/bricks/manifests/testimonials.manifest.ts +397 -0
- package/src/shared/bricks/manifests/tests/header.manifest.test.ts +10 -0
- package/src/shared/bricks/manifests/text.manifest.ts +164 -0
- package/src/shared/bricks/manifests/timeline.manifest.ts +456 -0
- package/src/shared/bricks/manifests/video.manifest.ts +59 -0
- package/src/shared/bricks/props/_style-presets.ts +352 -0
- package/src/shared/bricks/props/align.ts +59 -0
- package/src/shared/bricks/props/background.ts +118 -0
- package/src/shared/bricks/props/boolean.ts +11 -0
- package/src/shared/bricks/props/border.ts +84 -0
- package/src/shared/bricks/props/color.ts +24 -0
- package/src/shared/bricks/props/common.ts +37 -0
- package/src/shared/bricks/props/container.ts +356 -0
- package/src/shared/bricks/props/css-length.ts +25 -0
- package/src/shared/bricks/props/datasource.ts +60 -0
- package/src/shared/bricks/props/date.ts +24 -0
- package/src/shared/bricks/props/effects.ts +123 -0
- package/src/shared/bricks/props/enum.ts +42 -0
- package/src/shared/bricks/props/file.ts +12 -0
- package/src/shared/bricks/props/geolocation.ts +30 -0
- package/src/shared/bricks/props/helpers.ts +101 -0
- package/src/shared/bricks/props/image.ts +90 -0
- package/src/shared/bricks/props/number.ts +16 -0
- package/src/shared/bricks/props/padding.ts +21 -0
- package/src/shared/bricks/props/position.ts +27 -0
- package/src/shared/bricks/props/preset.ts +136 -0
- package/src/shared/bricks/props/string.ts +60 -0
- package/src/shared/bricks/props/tests/align.test.ts +37 -0
- package/src/shared/bricks/props/tests/background.test.ts +102 -0
- package/src/shared/bricks/props/tests/border.test.ts +38 -0
- package/src/shared/bricks/props/tests/effects.test.ts +37 -0
- package/src/shared/bricks/props/tests/helpers.test.ts +133 -0
- package/src/shared/bricks/props/tests/image.test.ts +71 -0
- package/src/shared/bricks/props/tests/padding.ts +12 -0
- package/src/shared/bricks/props/tests/string.test.ts +79 -0
- package/src/shared/bricks/props/text.ts +66 -0
- package/src/shared/bricks/props/types.ts +57 -0
- package/src/shared/bricks.ts +232 -0
- package/src/shared/context.ts +39 -0
- package/src/shared/datarecords/external/airtable/handler.ts +21 -0
- package/src/shared/datarecords/external/airtable/options.ts +22 -0
- package/src/shared/datarecords/external/generic-webhook/handler.ts +10 -0
- package/src/shared/datarecords/external/generic-webhook/options.ts +13 -0
- package/src/shared/datarecords/external/google/oauth/config.ts +30 -0
- package/src/shared/datarecords/external/google/sheets/handler.ts +26 -0
- package/src/shared/datarecords/external/google/sheets/options.ts +9 -0
- package/src/shared/datarecords/types.ts +120 -0
- package/src/shared/datarecords.ts +5 -0
- package/src/shared/datasources/README.md +3 -0
- package/src/shared/datasources/external/facebook/posts/fetcher.ts +53 -0
- package/src/shared/datasources/external/facebook/posts/sample.ts +35 -0
- package/src/shared/datasources/external/facebook/posts/schema.ts +33 -0
- package/src/shared/datasources/external/facebook/posts/tests/fetcher.test.ts +73 -0
- package/src/shared/datasources/external/http-json/fetcher.ts +28 -0
- package/src/shared/datasources/external/http-json/options.ts +12 -0
- package/src/shared/datasources/external/http-json/schema.ts +6 -0
- package/src/shared/datasources/external/http-json/tests/fetcher.test.ts +70 -0
- package/src/shared/datasources/external/instagram/feed/fetcher.ts +42 -0
- package/src/shared/datasources/external/instagram/feed/sample.ts +22 -0
- package/src/shared/datasources/external/instagram/feed/schema.ts +23 -0
- package/src/shared/datasources/external/instagram/feed/tests/fetcher.test.ts +82 -0
- package/src/shared/datasources/external/mastodon/account/fetcher.ts +32 -0
- package/src/shared/datasources/external/mastodon/account/sample.ts +33 -0
- package/src/shared/datasources/external/mastodon/account/schema.ts +45 -0
- package/src/shared/datasources/external/mastodon/account/tests/fetcher.test.ts +65 -0
- package/src/shared/datasources/external/mastodon/options.ts +11 -0
- package/src/shared/datasources/external/mastodon/status/fetcher.ts +36 -0
- package/src/shared/datasources/external/mastodon/status/sample.array.ts +59 -0
- package/src/shared/datasources/external/mastodon/status/sample.single.ts +55 -0
- package/src/shared/datasources/external/mastodon/status/schema.ts +130 -0
- package/src/shared/datasources/external/mastodon/status/tests/fetcher.test.ts +74 -0
- package/src/shared/datasources/external/meta/oauth/config.ts +16 -0
- package/src/shared/datasources/external/meta/options.ts +11 -0
- package/src/shared/datasources/external/rss/fetcher.ts +29 -0
- package/src/shared/datasources/external/rss/options.ts +11 -0
- package/src/shared/datasources/external/rss/sample.ts +22 -0
- package/src/shared/datasources/external/rss/schema.ts +42 -0
- package/src/shared/datasources/external/threads/media/fetcher.ts +62 -0
- package/src/shared/datasources/external/threads/media/sample.ts +44 -0
- package/src/shared/datasources/external/threads/media/schema.ts +37 -0
- package/src/shared/datasources/external/tiktok/oauth/config.ts +17 -0
- package/src/shared/datasources/external/tiktok/video/fetcher.ts +40 -0
- package/src/shared/datasources/external/tiktok/video/options.ts +12 -0
- package/src/shared/datasources/external/tiktok/video/sample.ts +26 -0
- package/src/shared/datasources/external/tiktok/video/schema.ts +27 -0
- package/src/shared/datasources/external/youtube/list/fetcher.ts +38 -0
- package/src/shared/datasources/external/youtube/list/options.ts +15 -0
- package/src/shared/datasources/external/youtube/list/sample.ts +33 -0
- package/src/shared/datasources/external/youtube/list/schema.ts +38 -0
- package/src/shared/datasources/external/youtube/oauth/config.ts +15 -0
- package/src/shared/datasources/fetcher.ts +17 -0
- package/src/shared/datasources/internal/blog/schema.ts +69 -0
- package/src/shared/datasources/internal/changelog/schema.ts +48 -0
- package/src/shared/datasources/internal/contact-info/schema.ts +20 -0
- package/src/shared/datasources/internal/cv/schema.ts +217 -0
- package/src/shared/datasources/internal/faq/schema.ts +27 -0
- package/src/shared/datasources/internal/job-board/schema.ts +228 -0
- package/src/shared/datasources/internal/links/schema.ts +15 -0
- package/src/shared/datasources/internal/recipes/schema.ts +42 -0
- package/src/shared/datasources/internal/restaurant/schema.ts +225 -0
- package/src/shared/datasources/provider-options.ts +7 -0
- package/src/shared/datasources/samples.ts +26 -0
- package/src/shared/datasources/schemas.ts +45 -0
- package/src/shared/datasources/types.ts +276 -0
- package/src/shared/datasources/utils.ts +16 -0
- package/src/shared/datasources.ts +42 -0
- package/src/shared/env.ts +23 -0
- package/src/shared/errors.ts +1 -0
- package/src/shared/images.ts +44 -0
- package/src/shared/index.ts +3 -0
- package/src/shared/layout-constants.ts +25 -0
- package/src/shared/manifest.ts +50 -0
- package/src/shared/oauth.ts +16 -0
- package/src/shared/page.ts +61 -0
- package/src/shared/prompt.ts +9 -0
- package/src/shared/responsive.ts +5 -0
- package/src/shared/site.ts +97 -0
- package/src/shared/sitemap.ts +66 -0
- package/src/shared/social-icons.ts +307 -0
- package/src/shared/tests/attributes.test.ts +37 -0
- package/src/shared/theme.ts +245 -0
- package/src/shared/themes/README.md +34 -0
- package/src/shared/themes/color-system.ts +127 -0
- package/src/shared/utils/canvas-data-uri.ts +2 -0
- package/src/shared/utils/invariant.ts +25 -0
- package/src/shared/utils/json-date.ts +8 -0
- package/src/shared/utils/merge.ts +12 -0
- package/src/shared/utils/object-hash.ts +7 -0
- package/src/shared/utils/schema.ts +30 -0
- package/src/shared/utils/try-catch.ts +12 -0
- package/src/shared/utils/typed-ref.ts +41 -0
- package/dist/shared/bricks/manifests/countdown.manifest.d.ts +0 -57
- package/dist/shared/bricks/manifests/countdown.manifest.d.ts.map +0 -1
- package/dist/shared/bricks/manifests/countdown.manifest.js +0 -3
- package/dist/shared/bricks/manifests/generic-component.manifest.d.ts +0 -62
- package/dist/shared/bricks/manifests/generic-component.manifest.d.ts.map +0 -1
- package/dist/shared/bricks/manifests/generic-component.manifest.js +0 -3
- package/dist/shared/bricks/manifests/header.manifest.d.ts +0 -275
- package/dist/shared/bricks/manifests/header.manifest.d.ts.map +0 -1
- package/dist/shared/bricks/manifests/header.manifest.js +0 -3
- package/dist/shared/bricks/props/_docs-common-styles.d.ts +0 -59
- package/dist/shared/bricks/props/_docs-common-styles.d.ts.map +0 -1
- package/dist/shared/bricks/props/_docs-common-styles.js +0 -3
- package/dist/shared/bricks/props/tests/container.test.d.ts +0 -2
- package/dist/shared/bricks/props/tests/container.test.d.ts.map +0 -1
- package/dist/shared/chunk-2ZPY4LCA.js +0 -3
- package/dist/shared/chunk-3CY6AZG7.js +0 -3
- package/dist/shared/chunk-4K5NN4CN.js +0 -3
- package/dist/shared/chunk-4NCCSLBW.js +0 -3
- package/dist/shared/chunk-6I4PY5WS.js +0 -3
- package/dist/shared/chunk-6LDLGZUM.js +0 -3
- package/dist/shared/chunk-AZ63RF3K.js +0 -3
- package/dist/shared/chunk-BH4HTAAC.js +0 -3
- package/dist/shared/chunk-BK6LBWDI.js +0 -3
- package/dist/shared/chunk-BMDB2V7J.js +0 -3
- package/dist/shared/chunk-DAPQ4JPP.js +0 -3
- package/dist/shared/chunk-ECZ6FGZM.js +0 -3
- package/dist/shared/chunk-EFJQECVB.js +0 -3
- package/dist/shared/chunk-F2ZVIFHO.js +0 -3
- package/dist/shared/chunk-H6L4KRCJ.js +0 -3
- package/dist/shared/chunk-IWSVY2VC.js +0 -3
- package/dist/shared/chunk-JVDUEZYO.js +0 -3
- package/dist/shared/chunk-KB4HY432.js +0 -3
- package/dist/shared/chunk-KOTGMAXH.js +0 -3
- package/dist/shared/chunk-LDOM2LJF.js +0 -3
- package/dist/shared/chunk-NFU5BF6G.js +0 -3
- package/dist/shared/chunk-P5FVZ5PL.js +0 -3
- package/dist/shared/chunk-PD7P5KSV.js +0 -3
- package/dist/shared/chunk-PJ6HA55L.js +0 -3
- package/dist/shared/chunk-PSNFBHPU.js +0 -3
- package/dist/shared/chunk-PSSJMWGU.js +0 -3
- package/dist/shared/chunk-PU2FOOTY.js +0 -3
- package/dist/shared/chunk-Q4MXTCE4.js +0 -8
- package/dist/shared/chunk-RBYYMUOZ.js +0 -3
- package/dist/shared/chunk-S2RQWOG2.js +0 -3
- package/dist/shared/chunk-SO5M7CYA.js +0 -3
- package/dist/shared/chunk-THRRILTW.js +0 -3
- package/dist/shared/chunk-TQ23UATQ.js +0 -3
- package/dist/shared/chunk-U44NTSIO.js +0 -3
- package/dist/shared/chunk-U4R5EGBK.js +0 -3
- package/dist/shared/chunk-WOEBR25A.js +0 -3
- package/dist/shared/chunk-WPTVLIYS.js +0 -3
- package/dist/shared/chunk-WXKRIUTA.js +0 -3
- package/dist/shared/chunk-XBX6II3M.js +0 -3
- package/dist/shared/chunk-XEQ2XZLQ.js +0 -3
- package/dist/shared/chunk-XGCBIXOO.js +0 -3
- package/dist/shared/chunk-YY6DANZF.js +0 -3
- package/dist/shared/chunk-ZWQHIQEQ.js +0 -3
- package/dist/shared/datasources/external/json/fetcher.d.ts.map +0 -1
- package/dist/shared/datasources/external/json/options.d.ts.map +0 -1
- package/dist/shared/datasources/external/json/schema.d.ts.map +0 -1
- package/dist/shared/datasources/external/json/tests/fetcher.test.d.ts.map +0 -1
- package/dist/shared/datasources/external/rss/tests/fetcher.test.d.ts +0 -2
- package/dist/shared/datasources/external/rss/tests/fetcher.test.d.ts.map +0 -1
- package/dist/shared/template.d.ts +0 -898
- package/dist/shared/template.d.ts.map +0 -1
- package/dist/shared/template.js +0 -3
- package/dist/shared/tests/page.test.d.ts +0 -2
- package/dist/shared/tests/page.test.d.ts.map +0 -1
- package/dist/shared/tests/test-config.d.ts +0 -3
- package/dist/shared/tests/test-config.d.ts.map +0 -1
- package/dist/shared/themes/all-themes.d.ts +0 -3
- package/dist/shared/themes/all-themes.d.ts.map +0 -1
- package/dist/shared/themes/all-themes.js +0 -3
- /package/dist/shared/datasources/external/{json → http-json}/fetcher.d.ts +0 -0
- /package/dist/shared/datasources/external/{json → http-json}/options.d.ts +0 -0
- /package/dist/shared/datasources/external/{json → http-json}/tests/fetcher.test.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/node/cli/utils.ts","../../../../../src/node/cli/constants.ts","../../../../../src/node/cli/store.ts","../../../../../package.json","../../../../../src/node/shared/logger.ts","../../../../../src/node/cli/api.ts","../../../../../src/node/cli/commands/publish/cmd-publish.ts","../../../../../src/node/cli/commands/publish/uploader.ts","../../../../../src/node/cli/commands/publish/parse-gitignore.ts","../../../../../src/node/shared/config.ts","../../../../../src/node/cli/is-logged-in.ts"],"sourcesContent":["export function getPackageManager() {\n // Detect package manager\n let packageManager: string | undefined;\n if (process.env.npm_config_user_agent) {\n const pmPart = process.env.npm_config_user_agent.split(\" \")[0];\n packageManager = pmPart.slice(0, pmPart.lastIndexOf(\"/\"));\n }\n\n // Display message\n if (!packageManager) {\n console.log(\"Warning: could not detect package manager\");\n packageManager = \"npm\";\n }\n\n return packageManager;\n}\n\nexport function formatAPIError(error: { error: string; error_description?: string }) {\n return `[${error.error}]${error.error_description ? `: ${error.error_description}` : \"\"}`;\n}\n","export const CLI_PROJECT_NAME = \"upstart-cli\";\nexport const CLI_LOGIN_POLL_INTERVAL = 5000; // seconds\nexport const CLI_LOGIN_CLIENT_ID =\n process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID ?? \"50000000-0000-0000-0000-000000000001\";\n\nexport const API_BASE_URL = process.env.PUBLIC_UPSTART_API_BASE_URL ?? \"https://api.upstart.gg\";\nexport const EDITOR_BASE_URL = process.env.PUBLIC_UPSTART_EDITOR_BASE_URL ?? \"https://upstart.gg\";\nexport const DEFAULT_UPLOAD_MAX_CONCURRENCY = 10;\n\nexport const OAUTH_ENDPOINT_DEVICE_CODE = \"oauth/devicecode\";\nexport const OAUTH_ENDPOINT_TOKEN = \"oauth/token\";\nexport const OAUTH_ENDPOINT_USER_INFO = \"oauth/userinfo\";\n\nexport const API_ENDPOINT_REGISTER_TEMPLATE = \"v1/templates\";\n","import type { CredentialsStore } from \"./types\";\nimport { CLI_PROJECT_NAME, OAUTH_ENDPOINT_USER_INFO } from \"./constants\";\nimport Conf from \"conf\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { getPackageManager } from \"./utils\";\nimport chalk from \"chalk\";\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\nconst key = getKey();\nconst accessStore = new Conf<CredentialsStore>({\n projectName: CLI_PROJECT_NAME,\n encryptionKey: key,\n clearInvalidConfig: true,\n});\n\n/**\n * Get access token or throw error if not found\n */\nexport function getTokenOrThrow() {\n const token = accessStore.get(\"access_token\");\n if (!token) {\n const pkgCmd = getPackageManager();\n throw new Error(\n `Access token not found. Please run ${chalk.cyan(`${pkgCmd} run enpage:login`)} to authenticate.`,\n );\n }\n return token;\n}\n\nfunction findNearestNodeModules(): string | null {\n let currentDir = __dirname;\n while (currentDir !== path.parse(currentDir).root) {\n const nodeModulesPath = path.join(currentDir, \"node_modules\");\n if (fs.existsSync(nodeModulesPath)) {\n return nodeModulesPath;\n }\n currentDir = path.dirname(currentDir);\n }\n return null;\n}\n\nfunction getKey() {\n const nodeModulesPath = findNearestNodeModules();\n if (!nodeModulesPath) {\n throw new Error(\"Could not find nearest node_modules directory.\");\n }\n const tmpSecureStoreDir = path.join(nodeModulesPath, \".enpage-tmp\");\n if (!fs.existsSync(tmpSecureStoreDir)) {\n fs.mkdirSync(tmpSecureStoreDir, { recursive: true, mode: 0o700 });\n }\n const keyPath = path.join(tmpSecureStoreDir, \".enpage-key\");\n if (!fs.existsSync(keyPath)) {\n const key = crypto.randomBytes(32).toString(\"hex\");\n fs.writeFileSync(keyPath, key, { mode: 0o600 });\n return key;\n }\n const key = fs.readFileSync(keyPath, \"utf8\");\n return key;\n}\n\nexport { accessStore };\n","{\n \"name\": \"@upstart.gg/sdk\",\n \"version\": \"0.0.96\",\n \"type\": \"module\",\n \"files\": [\n \"dist\",\n \"env.d.ts\"\n ],\n \"sideEffects\": true,\n \"exports\": {\n \".\": {\n \"import\": \"./dist/shared/index.js\",\n \"types\": \"./dist/shared/index.d.ts\"\n },\n \"./shared/*\": {\n \"types\": \"./dist/shared/*.d.ts\",\n \"import\": \"./dist/shared/*.js\"\n },\n \"./builder/*\": {\n \"import\": \"./dist/node/builder/*.js\"\n },\n \"./cli/*\": {\n \"import\": \"./dist/node/cli/*.js\"\n },\n \"./env.d.ts\": {\n \"types\": \"./env.d.ts\",\n \"require\": \"./env.d.ts\",\n \"import\": \"./env.d.ts\"\n },\n \"./*\": {\n \"types\": \"./dist/shared/*.d.ts\",\n \"import\": \"./dist/shared/*.js\"\n }\n },\n \"dependencies\": {\n \"@date-fns/utc\": \"1.2.0\",\n \"@headlessui/react\": \"2.2.1\",\n \"@inquirer/prompts\": \"5.3.8\",\n \"@radix-ui/react-context-menu\": \"2.2.2\",\n \"@radix-ui/react-toggle-group\": \"1.1.0\",\n \"@radix-ui/themes\": \"3.1.4\",\n \"@sinclair/typebox\": \"0.33.7\",\n \"@upstart.gg/style-system\": \"workspace:*\",\n \"ajv\": \"8.17.1\",\n \"ajv-formats\": \"3.0.1\",\n \"chalk\": \"5.3.0\",\n \"chroma-js\": \"3.1.2\",\n \"commander\": \"12.1.0\",\n \"conf\": \"13.0.1\",\n \"date-fns\": \"3.6.0\",\n \"debug\": \"4.3.6\",\n \"fast-glob\": \"3.3.2\",\n \"form-data\": \"4.0.0\",\n \"get-port\": \"7.1.0\",\n \"htmlparser2\": \"9.1.0\",\n \"http-errors-enhanced\": \"2.0.8\",\n \"immer\": \"10.1.1\",\n \"import-meta-resolve\": \"4.1.0\",\n \"lodash-es\": \"4.17.21\",\n \"nanoid\": \"5.0.7\",\n \"open\": \"10.1.0\",\n \"ora\": \"8.1.0\",\n \"p-queue\": \"8.0.1\",\n \"react-hotkeys-hook\": \"4.5.1\",\n \"react-icons\": \"5.3.0\",\n \"react-selecto\": \"1.26.3\",\n \"rollup-plugin-strip-banner\": \"3.1.0\",\n \"usehooks-ts\": \"3.1.0\",\n \"zundo\": \"2.3.0\",\n \"zustand\": \"4.5.5\"\n },\n \"peerDependencies\": {\n \"@upstart.gg/style-system\": \"workspace:*\",\n \"react\": \"18.3.0-canary-3d9b20132-20240124\",\n \"react-dom\": \"18.3.0-canary-3d9b20132-20240124\"\n },\n \"devDependencies\": {\n \"@cloudflare/workers-types\": \"4.20240806.0\",\n \"@types/chroma-js\": \"2.4.4\",\n \"@types/cli-progress\": \"3.11.6\",\n \"@types/debug\": \"4.1.12\",\n \"@types/express\": \"^4.17.21\",\n \"@types/lodash-es\": \"4.17.12\",\n \"@types/node\": \"^20.14.10\",\n \"@types/react\": \"18.3.3\",\n \"@types/react-dom\": \"^18.3.0\",\n \"@types/sortablejs\": \"1.15.8\",\n \"@vitejs/plugin-react\": \"^4.3.4\",\n \"concurrently\": \"8.2.2\",\n \"express\": \"^4.21.2\",\n \"rimraf\": \"6.0.1\",\n \"tsup\": \"8.2.4\",\n \"vite\": \"5.4.6\",\n \"vite-plugin-dts\": \"4.2.1\",\n \"vite-plugin-image-optimizer\": \"1.1.8\",\n \"vite-plugin-inspect\": \"0.8.7\",\n \"vite-plugin-virtual\": \"0.3.0\",\n \"vite-tsconfig-paths\": \"5.0.1\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"build:types\": \"tsc --emitDeclarationOnly --declaration --declarationMap\",\n \"dev\": \"NODE_OPTIONS='--max-old-space-size=12384' tsup --watch\",\n \"sizetest\": \"pnpm build && du -sh dist\",\n \"lint\": \"biome check --write . && tsc --noEmit\",\n \"ci:lint\": \"tsc --noEmit\",\n \"test\": \"vitest\",\n \"gen-ia-docs\": \"tsx scripts/generate-ia-docs.ts\"\n },\n \"author\": \"Matthias Etienne\",\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n","import {\n createLogger as createLoggerBase,\n type LogLevel,\n type LogOptions,\n type Logger as BaseLogger,\n} from \"vite\";\nimport { version } from \"../../../package.json\";\nimport chalk from \"chalk\";\n\ntype UpstartLoggerLevel = LogLevel | \"debug\";\n\nexport function createLogger(level?: UpstartLoggerLevel, allowClearScreen?: boolean, showVersion = false) {\n // vite logger does not support \"debug\" level\n const logger = createLoggerBase(level === \"debug\" ? \"info\" : level, {\n prefix: \"[upstart]\",\n allowClearScreen,\n });\n\n if (showVersion) {\n logger.info(chalk.hex(\"#7270c6\").bold(`🚀 Upstart v${version}\\n`));\n }\n\n return {\n ...logger,\n success: (message: string, options?: LogOptions) => logger.info(chalk.green(message), options),\n error: (message: string, options?: LogOptions) => logger.error(chalk.red(message), options),\n warn: (message: string, options?: LogOptions) => logger.warn(chalk.yellow(message), options),\n warnOnce: (message: string, options?: LogOptions) => logger.warnOnce(chalk.yellow(message), options),\n debug: (message: string, options?: LogOptions) => {\n if (level === \"debug\") {\n logger.info(chalk.gray(message), options);\n }\n },\n };\n}\n\nexport const logger = createLogger();\n\nexport type Logger = BaseLogger & {\n success: (message: string, options?: LogOptions) => void;\n debug: (message: string, options?: LogOptions) => void;\n};\n","import { logger } from \"../shared/logger\";\nimport { API_BASE_URL } from \"./constants\";\nimport { accessStore } from \"./store\";\n\ntype SuccessResponseWrapper<T> = {\n isSuccess: true;\n isError: false;\n status: number;\n statusText: string;\n data: T;\n};\n\ntype ErrorResponseWrapper<E> = {\n isSuccess: false;\n isError: true;\n status: number;\n statusText: string;\n data: E;\n};\n\ntype ResponseWrapper<T, E> = SuccessResponseWrapper<T> | ErrorResponseWrapper<E>;\n\ntype CommonResponseType = {\n success: boolean;\n};\n\n/**\n *\n * @param pathOrUrl\n * @param data\n * @returns\n */\nexport async function post<\n ResponseType extends CommonResponseType = CommonResponseType,\n ErrorType = { error: string; error_description?: string },\n>(path: string, data: Record<string, unknown> | URLSearchParams, headers: Record<string, string> = {}) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), {\n method: \"POST\",\n headers: {\n \"Content-Type\":\n data instanceof URLSearchParams ? \"application/x-www-form-urlencoded\" : \"application/json\",\n ...headers,\n },\n body: data instanceof URLSearchParams ? data : JSON.stringify(data),\n }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nexport async function get<ResponseType = unknown, ErrorType = { error: string; error_description?: string }>(\n path: string,\n headers: Record<string, string> = {},\n) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), { headers, method: \"GET\" }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nfunction toURL(path: string) {\n const apiBaseURL = new URL(API_BASE_URL.endsWith(\"/\") ? API_BASE_URL : `${API_BASE_URL}/`);\n return new URL(path, apiBaseURL);\n}\n\nasync function formatResponse<SuccessType, ErrorType>(\n response: Response,\n): Promise<ResponseWrapper<SuccessType, ErrorType>> {\n const data = response.headers.get(\"content-type\")?.startsWith(\"application/json\")\n ? ((await response.json()) as ResponseType)\n : ((await response.text()) as ResponseType);\n\n if (response.ok) {\n return {\n isSuccess: true,\n isError: false,\n status: response.status,\n statusText: response.statusText,\n data: data as SuccessType,\n };\n } else {\n return {\n isSuccess: false,\n isError: true,\n status: response.status,\n statusText: response.statusText,\n data: data as ErrorType,\n };\n }\n}\n","import { resolve } from \"node:path\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport chalk from \"chalk\";\nimport type { CommandArgOpts } from \"../../types\";\nimport { formatAPIError, getPackageManager } from \"../../utils\";\nimport { getTokenOrThrow } from \"../../store\";\nimport { uploadTemplate } from \"./uploader\";\nimport path from \"node:path\";\nimport { post } from \"../../api\";\nimport { API_ENDPOINT_REGISTER_TEMPLATE } from \"../../constants\";\nimport { loadConfigFromJsFile, validateTemplateConfig } from \"~/node/shared/config\";\nimport { isLoggedIn } from \"../../is-logged-in\";\n\nexport async function publish({ options, args, logger }: CommandArgOpts) {\n // check if user is logged in\n if (!(await isLoggedIn(true))) {\n const pkgCmd = getPackageManager();\n logger.error(\n ` ${chalk.redBright(\"Error\")}: User token not found. Please run ${chalk.cyan(`${pkgCmd} run enpage:login`)} to authenticate or set the ${chalk.cyan(\"ENPAGE_API_TOKEN\")} environment variable.\\n`,\n );\n process.exit(1);\n }\n\n const templateDir = args.length\n ? path.isAbsolute(args[0])\n ? args[0]\n : resolve(process.cwd(), args[0])\n : process.cwd();\n\n if (!existsSync(templateDir)) {\n logger.error(` Template directory not found: ${templateDir}. Aborting.\\n`);\n process.exit(1);\n }\n\n const distDir =\n args.length > 1\n ? path.isAbsolute(args[1])\n ? args[1]\n : resolve(process.cwd(), args[1])\n : resolve(templateDir, \"dist\");\n\n if (!existsSync(distDir)) {\n logger.error(\n ` Dist directory not found: ${distDir}.\\n Please run 'build' before publishing. Aborting.\\n`,\n );\n process.exit(1);\n }\n\n // check if enpage.config.js and package.json exist in the current directory\n // if not, exit with an error\n if (!existsSync(resolve(templateDir, \"enpage.config.js\"))) {\n logger.error(\n ` ${chalk.redBright(\"Error\")}: file enpage.config.js not found in ${templateDir}. Aborting.\\n`,\n );\n process.exit(1);\n }\n\n // load manifest from both enpage.config.js and package.json\n // manifest.json is used to store the template ID for future updates\n const config = await loadConfigFromJsFile(resolve(templateDir, \"enpage.config.js\"), logger);\n\n validateTemplateConfig(config, logger);\n\n const token = getTokenOrThrow();\n const pkgLocation = getPackageLocation(templateDir);\n\n if (!pkgLocation) {\n logger.error(` ${chalk.redBright(\"Error\")}: package.json file not found in ${templateDir}. Aborting.\\n`);\n process.exit(1);\n }\n\n // load package.json to get the template ID (if it exists)\n const pkg = await getPackageJsonContents(pkgLocation);\n\n if (!pkg) {\n logger.error(\n ` ${chalk.redBright(\"Error\")}: cannot read/parse package.json file in ${templateDir}. Aborting.\\n`,\n );\n process.exit(1);\n }\n\n if (!pkg.enpage?.id) {\n // call API to create a new template\n const { data, isError, status } = await post<{ success: true; template: { id: string } }>(\n API_ENDPOINT_REGISTER_TEMPLATE,\n {\n manifest: config.manifest,\n },\n );\n if (isError) {\n logger.error(` ${chalk.redBright(\"Error\")}: Cannot register template: ${formatAPIError(data)}\\n`);\n process.exit(1);\n }\n pkg.enpage ??= {};\n pkg.enpage.id = data.template.id;\n\n // save the template ID to package.json\n try {\n if (!options.dryRun) writeFileSync(pkgLocation, JSON.stringify(pkg, null, 2));\n } catch (e) {\n logger.error(\n ` ${chalk.redBright(\"Error\")}: Cannot update template id in package.json file located in ${templateDir}. Aborting.\\n`,\n );\n process.exit(1);\n }\n }\n\n const templateId = pkg.enpage.id;\n\n // submit template to Enpage\n logger.info(`Submitting template to Enpage...\\n`);\n\n const uploadResults = await uploadTemplate(templateId, templateDir, token, options.dryRun);\n\n if (!uploadResults.success) {\n logger.error(\"\\nUpload failed. See details above.\\n\");\n process.exit(1);\n }\n\n logger.success(`Template ${templateId} published.\\n`);\n}\n\nfunction getPackageLocation(templateDir: string) {\n return existsSync(resolve(templateDir, \"package.json\"))\n ? resolve(templateDir, \"package.json\")\n : existsSync(resolve(templateDir, \"template-package.json\"))\n ? resolve(templateDir, \"template-package.json\")\n : false;\n}\n\nfunction getPackageJsonContents(pkgJsonPath: string) {\n try {\n return JSON.parse(readFileSync(pkgJsonPath, \"utf-8\"));\n } catch (e) {\n return null;\n }\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport crypto from \"node:crypto\";\nimport fg from \"fast-glob\";\nimport { API_BASE_URL, DEFAULT_UPLOAD_MAX_CONCURRENCY } from \"../../constants\";\nimport http from \"node:http\";\nimport https from \"node:https\";\nimport { pipeline } from \"node:stream\";\nimport type { GenericApiError } from \"../../types\";\nimport { logger } from \"~/node/shared/logger\";\nimport chalk from \"chalk\";\nimport FormData from \"form-data\";\nimport parseGitIgnore from \"./parse-gitignore\";\nimport PQueue from \"p-queue\";\nimport ora from \"ora\";\nimport { customAlphabet } from \"nanoid\";\nimport { post } from \"../../api\";\n\ninterface UploadStats {\n fileName: string;\n fileSize: number;\n uploadDuration: number;\n statusCode: number;\n serverResponse: string;\n}\n\nclass UploadError extends Error implements GenericApiError {\n constructor(\n public error: string,\n public error_description: string,\n public filename: string,\n ) {\n super(`${error}: ${error_description}`);\n this.name = \"UploadError\";\n }\n}\n\ninterface UploadConfig {\n maxDataSize: number;\n retryAttempts: number;\n retryDelay: number;\n}\n\nconst defaultConfig: UploadConfig = {\n maxDataSize: 12 * 1024 * 1024, // 12MB\n retryAttempts: 2,\n retryDelay: 1000,\n};\n\nconst agent = new http.Agent({\n keepAlive: true,\n maxSockets: 10,\n keepAliveMsecs: 3000, // Keep connections open for 3 seconds\n});\n\nasync function discoverFiles(templateDir: string): Promise<string[]> {\n const gitignore = path.join(templateDir, \".gitignore\");\n const gitignoreExists = fs.existsSync(gitignore);\n const gitignored = gitignoreExists ? parseGitIgnore(fs.readFileSync(gitignore, \"utf-8\")).patterns : [];\n\n return fg(\"**/*\", {\n cwd: templateDir,\n onlyFiles: true,\n dot: true,\n absolute: true,\n ignore: [\n \"node_modules/**\",\n \".cache/**\",\n \"**/.DS_Store\",\n \".gitignore\",\n \".env\",\n \".env.*\",\n \".git/**\",\n \"dist/**\",\n ...gitignored,\n ],\n });\n}\n\nasync function uploadFile(\n filePath: string,\n relativePath: string,\n uploadUrl: string,\n templateId: string,\n spinner: ReturnType<typeof ora>,\n token: string,\n config: UploadConfig,\n): Promise<UploadStats> {\n const uploadWithRetry = async (attempt: number): Promise<UploadStats> => {\n try {\n return await performUpload(filePath, relativePath, uploadUrl, templateId, spinner, token, config);\n } catch (error) {\n if (attempt < config.retryAttempts) {\n logger.warn(`Retrying upload for ${relativePath} (attempt ${attempt + 1})`);\n await new Promise((resolve) => setTimeout(resolve, config.retryDelay));\n return uploadWithRetry(attempt + 1);\n }\n throw error;\n }\n };\n\n return uploadWithRetry(0);\n}\n\nasync function performUpload(\n filePath: string,\n relativePath: string,\n uploadUrl: string,\n templateId: string,\n spinner: ReturnType<typeof ora>,\n token: string,\n config: UploadConfig,\n): Promise<UploadStats> {\n return new Promise<UploadStats>((resolve, reject) => {\n const stats = fs.statSync(filePath);\n const fileName = path.basename(filePath);\n const startTime = Date.now();\n\n const form = new FormData({\n maxDataSize: config.maxDataSize,\n });\n const fileStream = fs.createReadStream(filePath);\n let totalUploaded = 0;\n\n const updateProgress = (chunk: Buffer | string) => {\n totalUploaded += chunk.length;\n };\n\n fileStream.on(\"data\", updateProgress);\n form.append(\"file\", fileStream, {\n filename: fileName,\n knownLength: stats.size,\n });\n\n const options: https.RequestOptions = {\n agent,\n method: \"POST\",\n headers: {\n authorization: `Bearer ${token}`,\n \"x-upstart-template-file-path\": relativePath,\n \"x-upstart-template-id\": templateId,\n ...form.getHeaders(),\n },\n };\n\n const protocol = uploadUrl.startsWith(\"https\") ? https : http;\n const req = protocol.request(uploadUrl, options, (res) => {\n let responseBody = \"\";\n res.on(\"data\", (chunk) => {\n responseBody += chunk;\n });\n\n res.on(\"end\", () => {\n const endTime = Date.now();\n const uploadStats: UploadStats = {\n fileName,\n fileSize: stats.size,\n uploadDuration: endTime - startTime,\n statusCode: res.statusCode ?? 0,\n serverResponse: responseBody,\n };\n\n if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {\n spinner.text = `Uploaded ${relativePath}`;\n resolve(uploadStats);\n } else {\n let errorObject: UploadError;\n if (res.headers[\"content-type\"]?.startsWith(\"application/json\")) {\n const parsedError = JSON.parse(responseBody);\n errorObject = new UploadError(\n parsedError.error || \"unknown_error\",\n parsedError.error_description || \"Unknown error occurred\",\n relativePath,\n );\n } else {\n errorObject = new UploadError(\n \"unknown_error\",\n responseBody || \"Unknown error occurred\",\n relativePath,\n );\n }\n\n spinner.fail(\n `Failed to upload ${relativePath} [${errorObject.error}] ${errorObject.error_description}`,\n );\n\n reject(errorObject);\n }\n });\n });\n\n req.on(\"error\", (error) => {\n reject(new UploadError(\"request_error\", error.message, relativePath));\n });\n\n pipeline(form, req, (err) => {\n if (err) {\n reject(\n new UploadError(\"pipeline_error\", `Pipeline failed for ${fileName}: ${err.message}`, relativePath),\n );\n }\n });\n });\n}\n\nfunction reportUploadStatistics(\n templateId: string,\n uploadedFiles: UploadStats[],\n failedFiles: PromiseRejectedResult[],\n) {\n if (failedFiles.length > 0) {\n logger.error(chalk.red(`Failed to upload ${failedFiles.length} files:`));\n failedFiles.forEach((failure) => {\n const error = failure.reason as UploadError;\n logger.error(`- ${error.filename}: ${error.error_description} (${error.error})`);\n });\n } else {\n logger.info(\n chalk.green(`Uploaded ${uploadedFiles.length} files successfully for template ${templateId}.\\n`),\n );\n }\n}\n\nexport async function uploadTemplate(\n templateId: string,\n templateDir: string,\n token: string,\n dryRun = false,\n config: Partial<UploadConfig> = {},\n) {\n const fullConfig = { ...defaultConfig, ...config };\n const queue = new PQueue({ concurrency: DEFAULT_UPLOAD_MAX_CONCURRENCY });\n const files = await discoverFiles(templateDir);\n const filesCount = files.length;\n const signatures: Record<string, string> = {};\n // generate a upload id\n const uploadId = generateUploadId();\n let completedUploads = 0;\n\n // compute signatures\n for (const file of files) {\n const relativePath = path.relative(templateDir, file);\n const md5 = await sha1sum(file);\n signatures[relativePath] = md5;\n }\n\n if (dryRun) {\n logger.info(\"Dry run mode enabled. Skipping upload.\\n\");\n logger.info(\"The following files would have been uploaded:\");\n files.forEach((file) => logger.info(`- ${file}`));\n process.exit(0);\n }\n\n const spinner = ora(`Uploading ${filesCount} files...`).start();\n\n // upload files\n const uploadPromises = files.map((file) => {\n const fullPath = path.resolve(templateDir, file);\n const relativePath = path.relative(templateDir, file);\n const url = `${API_BASE_URL}/v1/templates/${templateId}/upload/${uploadId}`;\n return queue.add(async () => {\n const result = await uploadFile(fullPath, relativePath, url, templateId, spinner, token, fullConfig);\n completedUploads++;\n return result;\n });\n });\n\n const results = await Promise.allSettled(uploadPromises);\n spinner.stop();\n\n const uploadedFiles = results.filter(\n (result): result is PromiseFulfilledResult<UploadStats> => result.status === \"fulfilled\",\n );\n\n const failedFiles = results.filter(\n (result): result is PromiseRejectedResult => result.status === \"rejected\",\n );\n\n reportUploadStatistics(\n templateId,\n uploadedFiles.map((r) => r.value),\n failedFiles,\n );\n\n // finalize upload\n if (!failedFiles.length && uploadedFiles.length) {\n const finalizeUrl = `${API_BASE_URL}/v1/templates/${templateId}/upload/${uploadId}/finalize`;\n const finalizePayload = {\n signatures,\n };\n\n const finalizeResponse = await post(finalizeUrl, finalizePayload);\n\n if (finalizeResponse.isError) {\n logger.error(\n `Failed to finalize upload: ${finalizeResponse.data.error_description} (${finalizeResponse.data.error})`,\n );\n return {\n filesCount,\n uploadedFiles: uploadedFiles.map((r) => r.value),\n failedFiles: [],\n success: false,\n };\n }\n }\n\n return {\n filesCount,\n uploadedFiles: uploadedFiles.map((r) => r.value),\n failedFiles,\n success: failedFiles.length === 0,\n };\n}\n\nasync function sha1sum(filePath: string): Promise<string> {\n const hash = await crypto.subtle.digest(\"SHA-1\", fs.readFileSync(filePath));\n // convert arrayBuffer to hex\n return Array.from(new Uint8Array(hash))\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\nfunction generateUploadId(): string {\n const randomId = customAlphabet(\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\", 5);\n const now = new Date();\n const year = now.getUTCFullYear();\n const month = (now.getUTCMonth() + 1).toString().padStart(2, \"0\");\n const day = now.getUTCDate().toString().padStart(2, \"0\");\n const hours = now.getUTCHours().toString().padStart(2, \"0\");\n const minutes = now.getUTCMinutes().toString().padStart(2, \"0\");\n const seconds = now.getUTCSeconds().toString().padStart(2, \"0\");\n return `${year}${month}${day}${hours}${minutes}${seconds}_${randomId()}`;\n}\n","/*!\n * parse-gitignore <https://github.com/jonschlinkert/parse-gitignore>\n * Copyright (c) 2015-present, Jon Schlinkert.\n * Released under the MIT License.\n *\n * Converted to typescript by Matthias E. <matthias@upstart.gg>\n */\n\nimport * as fs from \"node:fs\";\n\n// eslint-disable-next-line no-control-regex\nconst INVALID_PATH_CHARS_REGEX = /[<>\"|?*\\n\\r\\t\\f\\x00-\\x1F]/;\nconst GLOBSTAR_REGEX = /(?:^|\\/)[*]{2}($|\\/)/;\nconst MAX_PATH_LENGTH = 260 - 12;\n\ninterface ParseOptions {\n path?: string;\n dedupe?: boolean;\n unique?: boolean;\n ignore?: string[];\n unignore?: string[];\n format?: boolean;\n formatSection?: (section: Section) => string;\n}\n\ninterface Section {\n name: string;\n comment?: string;\n patterns: string[];\n}\n\ninterface ParsedGitignore {\n sections: Section[];\n patterns: string[];\n path?: string;\n input: Buffer;\n format: (opts?: ParseOptions) => string;\n dedupe: (opts?: ParseOptions) => ParsedGitignore;\n globs: (opts?: ParseOptions) => GlobResult[];\n}\n\ninterface GlobResult {\n type: \"ignore\" | \"unignore\";\n path: string | null;\n patterns: string[];\n index: number;\n}\n\nconst isObject = (v: unknown): v is Record<string, unknown> =>\n v !== null && typeof v === \"object\" && !Array.isArray(v);\n\nconst isValidPath = (input: unknown): input is string =>\n typeof input === \"string\" && input.length <= MAX_PATH_LENGTH && !INVALID_PATH_CHARS_REGEX.test(input);\n\nconst split = (str: string): string[] => str.split(/\\r\\n?|\\n/);\nconst isComment = (str: string): boolean => str.startsWith(\"#\");\nconst isParsed = (input: unknown): input is ParsedGitignore =>\n isObject(input) && Array.isArray(input.patterns) && Array.isArray(input.sections);\n\nconst patterns = (input: string): string[] =>\n split(input)\n .map((l) => l.trim())\n .filter((line) => line !== \"\" && !isComment(line));\n\nconst parse = (input: string | ParsedGitignore, options: ParseOptions = {}): ParsedGitignore => {\n let filepath = options.path;\n\n if (isParsed(input)) return input;\n if (isValidPath(input) && fs.existsSync(input)) {\n filepath = input;\n input = fs.readFileSync(input, \"utf8\");\n }\n\n const lines = split(input);\n const names = new Map<string, Section>();\n\n let parsed: ParsedGitignore = { sections: [], patterns: [] } as unknown as ParsedGitignore;\n let section: Section = { name: \"default\", patterns: [] };\n let prev: Section | null = null;\n\n for (const line of lines) {\n const value = line.trim();\n\n if (value.startsWith(\"#\")) {\n const [, name] = /^#+\\s*(.*)\\s*$/.exec(value) || [];\n\n if (prev) {\n names.delete(prev.name);\n prev.comment = prev.comment ? `${prev.comment}\\n${value}` : value;\n prev.name = name ? `${prev.name.trim()}\\n${name.trim()}` : prev.name.trim();\n names.set(prev.name.toLowerCase().trim(), prev);\n continue;\n }\n\n section = { name: name?.trim() || \"\", comment: value, patterns: [] };\n names.set(section.name.toLowerCase(), section);\n parsed.sections.push(section);\n prev = section;\n continue;\n }\n\n if (value !== \"\") {\n section.patterns.push(value);\n parsed.patterns.push(value);\n }\n\n prev = null;\n }\n\n if (options.dedupe === true || options.unique === true) {\n parsed = dedupe(parsed, { ...options, format: false });\n }\n\n parsed.path = filepath;\n parsed.input = Buffer.from(input);\n parsed.format = (opts?: ParseOptions) => format(parsed, { ...options, ...opts });\n parsed.dedupe = (opts?: ParseOptions) => dedupe(parsed, { ...options, ...opts });\n parsed.globs = (opts?: ParseOptions) => globs(parsed, { path: filepath, ...options, ...opts });\n return parsed;\n};\n\nconst parseFile = (filepath: string, options?: ParseOptions): ParsedGitignore =>\n parse(fs.readFileSync(filepath, \"utf8\"), options);\n\nconst dedupe = (input: string | ParsedGitignore, options: ParseOptions): ParsedGitignore => {\n const parsed = parse(input, { ...options, dedupe: false });\n\n const names = new Map<string, Section>();\n const res: ParsedGitignore = { sections: [], patterns: [] } as unknown as ParsedGitignore;\n let current: Section;\n\n // first, combine duplicate sections\n for (const section of parsed.sections) {\n const { name = \"\", comment, patterns } = section;\n const key = name.trim().toLowerCase();\n\n for (const pattern of patterns) {\n if (!res.patterns.includes(pattern)) {\n res.patterns.push(pattern);\n }\n }\n\n if (name && names.has(key)) {\n current = names.get(key)!;\n current.patterns = [...current.patterns, ...patterns];\n } else {\n current = { name, comment, patterns };\n res.sections.push(current);\n names.set(key, current);\n }\n }\n\n // next, de-dupe patterns in each section\n for (const section of res.sections) {\n section.patterns = [...new Set(section.patterns)];\n }\n\n return res;\n};\n\nconst glob = (pattern: string): string => {\n // Return if a glob pattern has already been specified for sub-directories\n if (GLOBSTAR_REGEX.test(pattern)) {\n return pattern;\n }\n\n // If there is a separator at the beginning or middle (or both) of the pattern,\n // then the pattern is relative to the directory level of the particular .gitignore\n // file itself. Otherwise the pattern may also match at any level below the\n // .gitignore level. relative paths only\n let relative = false;\n if (pattern.startsWith(\"/\")) {\n pattern = pattern.slice(1);\n relative = true;\n } else if (pattern.slice(1, pattern.length - 1).includes(\"/\")) {\n relative = true;\n }\n\n // If there is a separator at the end of the pattern then the pattern will only match directories.\n pattern += pattern.endsWith(\"/\") ? \"**/\" : \"/**\";\n\n // If not relative, the pattern can match any files and directories.\n return relative ? pattern : `**/${pattern}`;\n};\n\nconst globs = (input: string | ParsedGitignore, options: ParseOptions = {}): GlobResult[] => {\n const parsed = parse(input, options);\n const result: GlobResult[] = [];\n let index = 0;\n\n const globPatterns = parsed.patterns\n .concat(options.ignore || [])\n .concat((options.unignore || []).map((p) => (!p.startsWith(\"!\") ? `!${p}` : p)));\n\n const push = (prefix: string, pattern: string) => {\n const prev = result[result.length - 1];\n const type = prefix ? \"unignore\" : \"ignore\";\n\n if (prev && prev.type === type) {\n if (!prev.patterns.includes(pattern)) {\n prev.patterns.push(pattern);\n }\n } else {\n result.push({ type, path: options.path || null, patterns: [pattern], index });\n index++;\n }\n };\n\n for (let pattern of globPatterns) {\n let prefix = \"\";\n\n // An optional prefix \"!\" which negates the pattern; any matching file excluded by\n // a previous pattern will become included again\n if (pattern.startsWith(\"!\")) {\n pattern = pattern.slice(1);\n prefix = \"!\";\n }\n\n // add the raw pattern to the results\n push(prefix, pattern.startsWith(\"/\") ? pattern.slice(1) : pattern);\n\n // add the glob pattern to the results\n push(prefix, glob(pattern));\n }\n\n return result;\n};\n\n/**\n * Formats a .gitignore section\n */\nconst formatSection = (section: Section = { name: \"\", patterns: [] }): string => {\n const output = [section.comment || \"\"];\n\n if (section.patterns?.length) {\n output.push(section.patterns.join(\"\\n\"));\n output.push(\"\");\n }\n\n return output.join(\"\\n\");\n};\n\n/**\n * Format a .gitignore file from the given input or object from `.parse()`.\n * @param {String | ParsedGitignore} input File path or contents.\n * @param {ParseOptions} options\n * @return {String} Returns formatted string.\n * @api public\n */\nconst format = (input: string | ParsedGitignore, options: ParseOptions = {}): string => {\n const parsed = parse(input, options);\n\n const fn = options.formatSection || formatSection;\n const sections = parsed.sections || parsed;\n const output: string[] = [];\n\n for (const section of ([] as Section[]).concat(sections)) {\n output.push(fn(section));\n }\n\n return output.join(\"\\n\");\n};\n\nexport {\n parse,\n parseFile,\n dedupe,\n format,\n globs,\n formatSection,\n patterns,\n type ParseOptions,\n type Section,\n type ParsedGitignore,\n type GlobResult,\n};\n\nexport default parse;\n","import { manifestSchema } from \"~/shared/manifest\";\nimport fs from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport fg from \"fast-glob\";\nimport { type Logger, logger as defaultLogger } from \"./logger\";\nimport { basename, dirname, extname } from \"node:path\";\nimport type { TemplateConfig } from \"~/shared/template\";\n\nexport async function loadConfigFromJsFile(\n configPath: string,\n logger = defaultLogger,\n): Promise<TemplateConfig> {\n if (!fs.existsSync(configPath)) {\n logger.error(\n \"🔴 No enpage.config.js found!\\nYour project must have an enpage.config.js file in the root directory.\\n\\n\",\n );\n process.exit(1);\n }\n const config = (await import(configPath)) as TemplateConfig;\n\n // Parse the readme files fro the same directory as the config file\n const readmePath = dirname(configPath);\n const readme: Record<string, string> = {};\n const readmeFiles = await fg([\"README.enpage.md\", \"README.enpage.*.md\"], {\n cwd: readmePath,\n onlyFiles: true,\n absolute: true,\n caseSensitiveMatch: false,\n });\n\n for (const file of readmeFiles) {\n const base = basename(file, \".md\");\n const ext = extname(base);\n const language = (ext === \".enpage\" ? \"en\" : ext.substring(1)).toLowerCase();\n logger.debug(`Found template readme file (${language}): ${basename(file)}`);\n readme[language] = await readFile(file, \"utf-8\");\n }\n\n if (config.manifest) {\n config.manifest.readme = readme;\n }\n\n return config;\n}\n\nexport function loadConfigFromManifestFile(manifestPath: string, logger: Logger): TemplateConfig {\n if (!fs.existsSync(manifestPath)) {\n logger.error(\"🔴 No enpage.manifest.json found!\\nYou may want to 'build' your template.\\n\\n\");\n process.exit(1);\n }\n return JSON.parse(fs.readFileSync(manifestPath, \"utf-8\"));\n}\n\nexport function validateTemplateConfig(config: TemplateConfig, logger: Logger) {\n for (const key in config.datasources) {\n if (\n (config.datasources[key].provider === \"json-object\" ||\n config.datasources[key].provider === \"json-array\") &&\n !config.datasources[key].sampleData\n ) {\n logger.error(\n `🔴 Error: Datasource \"${key}\" is missing sample data - nothing will be rendered during development! Please check your enpage.config.js file and add a \"sampleData\" key to your ${key} datasource.`,\n );\n throw new Error(`Missing sample data for datasource \"${key}\"`);\n }\n }\n\n // Todo: replace validation from zod to ajv\n // const validated = manifestSchema.safeParse(config.manifest);\n // if (!validated.success) {\n // logger.error(`🔴 Error: template manifest is invalid. Check your call to defineManifest().\\n`);\n // const err = fromError(validated.error);\n // logger.error(`Hint: ${err.toString()}\\n\\n`);\n // process.exit(1);\n // }\n\n return config;\n}\n","import { OAUTH_ENDPOINT_USER_INFO } from \"./constants\";\nimport { accessStore } from \"./store\";\n\nexport async function isLoggedIn(checkRemote = false): Promise<boolean> {\n const token = accessStore.get(\"access_token\");\n const expiration = accessStore.get(\"expires_at\");\n\n if (!token) {\n return false;\n }\n\n if (expiration && expiration < Date.now()) {\n console.log(\"Seems like your token expired...\");\n return false;\n }\n\n if (!checkRemote) {\n return true;\n }\n\n // Check if token is valid\n\n // import dynamically \"./api\" to avoid circular dependency\n const { get } = await import(\"./api\");\n const { isSuccess } = await get(OAUTH_ENDPOINT_USER_INFO);\n\n return isSuccess;\n}\n"],"mappings":";;gIAAO,SAASA,GAAoB,CAElC,IAAIC,EACJ,GAAI,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EAAK,KAAM,CAAC,CAAC,CAC9E,MAAY,CACVjB,EAAO,MACL,KAAKI,EAAM,UAAU,OAAO,CAAC,+DAA+DC,CAAW;AAAA,CACzG,EACA,QAAQ,KAAK,CAAC,CAChB,CACF,CAEA,IAAMqB,EAAaT,EAAI,OAAO,GAG9BjB,EAAO,KAAK;AAAA,CAAoC,GAE1B,MAAM2B,GAAeD,EAAYrB,EAAaQ,EAAOf,EAAQ,MAAM,GAEtE,UACjBE,EAAO,MAAM;AAAA;AAAA,CAAuC,EACpD,QAAQ,KAAK,CAAC,GAGhBA,EAAO,QAAQ,YAAY0B,CAAU;AAAA,CAAe,CACtD,CAEA,SAASV,GAAmBX,EAAqB,CAC/C,OAAOG,EAAWD,EAAQF,EAAa,cAAc,CAAC,EAClDE,EAAQF,EAAa,cAAc,EACnCG,EAAWD,EAAQF,EAAa,uBAAuB,CAAC,EACtDE,EAAQF,EAAa,uBAAuB,EAC5C,EACR,CAEA,SAASa,GAAuBU,EAAqB,CACnD,GAAI,CACF,OAAO,KAAK,MAAMC,GAAaD,EAAa,OAAO,CAAC,CACtD,MAAY,CACV,OAAO,IACT,CACF","names":["getPackageManager","packageManager","pmPart","formatAPIError","error","init_utils","__esmMin","CLI_PROJECT_NAME","CLI_LOGIN_CLIENT_ID","API_BASE_URL","EDITOR_BASE_URL","DEFAULT_UPLOAD_MAX_CONCURRENCY","OAUTH_ENDPOINT_USER_INFO","API_ENDPOINT_REGISTER_TEMPLATE","init_constants","__esmMin","Conf","path","crypto","fs","fileURLToPath","chalk","getTokenOrThrow","token","accessStore","pkgCmd","getPackageManager","findNearestNodeModules","currentDir","__dirname","nodeModulesPath","getKey","tmpSecureStoreDir","keyPath","key","init_store","__esmMin","init_constants","init_utils","CLI_PROJECT_NAME","version","init_package","__esmMin","createLoggerBase","chalk","createLogger","level","allowClearScreen","showVersion","logger","version","message","options","init_logger","__esmMin","init_package","api_exports","__export","get","post","path","data","headers","accessStore","response","toURL","error","logger","formatResponse","apiBaseURL","API_BASE_URL","init_api","__esmMin","init_logger","init_constants","init_store","init_utils","init_store","resolve","existsSync","readFileSync","writeFileSync","chalk","init_constants","init_logger","path","fs","crypto","fg","http","https","pipeline","chalk","FormData","fs","INVALID_PATH_CHARS_REGEX","GLOBSTAR_REGEX","MAX_PATH_LENGTH","isObject","v","isValidPath","input","split","str","isParsed","input","isObject","parse","input","options","filepath","isParsed","isValidPath","lines","split","names","parsed","section","prev","line","value","name","dedupe","opts","format","globs","dedupe","input","options","parsed","parse","names","res","current","section","name","comment","patterns","key","pattern","glob","GLOBSTAR_REGEX","relative","globs","result","index","globPatterns","p","push","prefix","prev","type","formatSection","output","format","fn","sections","parse_gitignore_default","parse","init_api","PQueue","ora","customAlphabet","UploadError","error","error_description","filename","defaultConfig","agent","http","discoverFiles","templateDir","gitignore","path","gitignored","fs","parse_gitignore_default","fg","uploadFile","filePath","relativePath","uploadUrl","templateId","spinner","token","config","uploadWithRetry","attempt","performUpload","logger","resolve","reject","stats","fileName","startTime","form","FormData","fileStream","totalUploaded","updateProgress","chunk","options","req","https","res","responseBody","endTime","uploadStats","errorObject","parsedError","pipeline","err","reportUploadStatistics","uploadedFiles","failedFiles","chalk","failure","uploadTemplate","dryRun","fullConfig","queue","DEFAULT_UPLOAD_MAX_CONCURRENCY","files","filesCount","signatures","uploadId","generateUploadId","completedUploads","file","md5","sha1sum","uploadPromises","fullPath","url","API_BASE_URL","result","results","r","finalizeUrl","finalizeResponse","post","hash","crypto","b","randomId","now","year","month","day","hours","minutes","seconds","init_api","init_constants","path","init_logger","fs","readFile","fg","basename","dirname","extname","loadConfigFromJsFile","configPath","logger","config","readmePath","readme","readmeFiles","file","base","ext","language","validateTemplateConfig","config","logger","key","init_constants","init_store","isLoggedIn","checkRemote","token","accessStore","expiration","get","isSuccess","OAUTH_ENDPOINT_USER_INFO","publish","options","args","logger","isLoggedIn","pkgCmd","getPackageManager","chalk","templateDir","path","resolve","existsSync","distDir","config","loadConfigFromJsFile","validateTemplateConfig","token","getTokenOrThrow","pkgLocation","getPackageLocation","pkg","getPackageJsonContents","data","isError","status","post","API_ENDPOINT_REGISTER_TEMPLATE","formatAPIError","writeFileSync","templateId","uploadTemplate","pkgJsonPath","readFileSync"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/node/cli/utils.ts","../../../../../src/node/cli/constants.ts","../../../../../src/node/cli/store.ts","../../../../../src/node/shared/logger.ts","../../../../../src/node/cli/api.ts","../../../../../src/node/cli/commands/publish/cmd-publish.ts","../../../../../src/node/cli/commands/publish/uploader.ts","../../../../../src/node/cli/commands/publish/parse-gitignore.ts","../../../../../src/node/shared/config.ts","../../../../../src/node/cli/is-logged-in.ts"],"sourcesContent":["export function getPackageManager() {\n // Detect package manager\n let packageManager: string | undefined;\n if (process.env.npm_config_user_agent) {\n const pmPart = process.env.npm_config_user_agent.split(\" \")[0];\n packageManager = pmPart.slice(0, pmPart.lastIndexOf(\"/\"));\n }\n\n // Display message\n if (!packageManager) {\n console.log(\"Warning: could not detect package manager\");\n packageManager = \"npm\";\n }\n\n return packageManager;\n}\n\nexport function formatAPIError(error: { error: string; error_description?: string }) {\n return `[${error.error}]${error.error_description ? `: ${error.error_description}` : \"\"}`;\n}\n","export const CLI_PROJECT_NAME = \"upstart-cli\";\nexport const CLI_LOGIN_POLL_INTERVAL = 5000; // seconds\nexport const CLI_LOGIN_CLIENT_ID =\n process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID ?? \"50000000-0000-0000-0000-000000000001\";\n\nexport const API_BASE_URL = process.env.PUBLIC_UPSTART_API_BASE_URL ?? \"https://api.upstart.gg\";\nexport const EDITOR_BASE_URL = process.env.PUBLIC_UPSTART_EDITOR_BASE_URL ?? \"https://upstart.gg\";\nexport const DEFAULT_UPLOAD_MAX_CONCURRENCY = 10;\n\nexport const OAUTH_ENDPOINT_DEVICE_CODE = \"oauth/devicecode\";\nexport const OAUTH_ENDPOINT_TOKEN = \"oauth/token\";\nexport const OAUTH_ENDPOINT_USER_INFO = \"oauth/userinfo\";\n\nexport const API_ENDPOINT_REGISTER_TEMPLATE = \"v1/templates\";\n","import type { CredentialsStore } from \"./types\";\nimport { CLI_PROJECT_NAME, OAUTH_ENDPOINT_USER_INFO } from \"./constants\";\nimport Conf from \"conf\";\nimport path from \"node:path\";\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport { fileURLToPath } from \"node:url\";\nimport { getPackageManager } from \"./utils\";\nimport chalk from \"chalk\";\n\nconst __dirname = fileURLToPath(new URL(\".\", import.meta.url));\nconst key = getKey();\nconst accessStore = new Conf<CredentialsStore>({\n projectName: CLI_PROJECT_NAME,\n encryptionKey: key,\n clearInvalidConfig: true,\n});\n\n/**\n * Get access token or throw error if not found\n */\nexport function getTokenOrThrow() {\n const token = accessStore.get(\"access_token\");\n if (!token) {\n const pkgCmd = getPackageManager();\n throw new Error(\n `Access token not found. Please run ${chalk.cyan(`${pkgCmd} run enpage:login`)} to authenticate.`,\n );\n }\n return token;\n}\n\nfunction findNearestNodeModules(): string | null {\n let currentDir = __dirname;\n while (currentDir !== path.parse(currentDir).root) {\n const nodeModulesPath = path.join(currentDir, \"node_modules\");\n if (fs.existsSync(nodeModulesPath)) {\n return nodeModulesPath;\n }\n currentDir = path.dirname(currentDir);\n }\n return null;\n}\n\nfunction getKey() {\n const nodeModulesPath = findNearestNodeModules();\n if (!nodeModulesPath) {\n throw new Error(\"Could not find nearest node_modules directory.\");\n }\n const tmpSecureStoreDir = path.join(nodeModulesPath, \".enpage-tmp\");\n if (!fs.existsSync(tmpSecureStoreDir)) {\n fs.mkdirSync(tmpSecureStoreDir, { recursive: true, mode: 0o700 });\n }\n const keyPath = path.join(tmpSecureStoreDir, \".enpage-key\");\n if (!fs.existsSync(keyPath)) {\n const key = crypto.randomBytes(32).toString(\"hex\");\n fs.writeFileSync(keyPath, key, { mode: 0o600 });\n return key;\n }\n const key = fs.readFileSync(keyPath, \"utf8\");\n return key;\n}\n\nexport { accessStore };\n","import {\n createLogger as createLoggerBase,\n type LogLevel,\n type LogOptions,\n type Logger as BaseLogger,\n} from \"vite\";\n// import { version } from \"../../../package.json\";\nimport chalk from \"chalk\";\n\nconst VERSION = 0.1;\n\ntype UpstartLoggerLevel = LogLevel | \"debug\";\n\nexport function createLogger(level?: UpstartLoggerLevel, allowClearScreen?: boolean, showVersion = false) {\n // vite logger does not support \"debug\" level\n const logger = createLoggerBase(level === \"debug\" ? \"info\" : level, {\n prefix: \"[upstart]\",\n allowClearScreen,\n });\n\n if (showVersion) {\n logger.info(chalk.hex(\"#7270c6\").bold(`🚀 Upstart v${VERSION}\\n`));\n }\n\n return {\n ...logger,\n success: (message: string, options?: LogOptions) => logger.info(chalk.green(message), options),\n error: (message: string, options?: LogOptions) => logger.error(chalk.red(message), options),\n warn: (message: string, options?: LogOptions) => logger.warn(chalk.yellow(message), options),\n warnOnce: (message: string, options?: LogOptions) => logger.warnOnce(chalk.yellow(message), options),\n debug: (message: string, options?: LogOptions) => {\n if (level === \"debug\") {\n logger.info(chalk.gray(message), options);\n }\n },\n };\n}\n\nexport const logger = createLogger();\n\nexport type Logger = BaseLogger & {\n success: (message: string, options?: LogOptions) => void;\n debug: (message: string, options?: LogOptions) => void;\n};\n","import { logger } from \"../shared/logger\";\nimport { API_BASE_URL } from \"./constants\";\nimport { accessStore } from \"./store\";\n\ntype SuccessResponseWrapper<T> = {\n isSuccess: true;\n isError: false;\n status: number;\n statusText: string;\n data: T;\n};\n\ntype ErrorResponseWrapper<E> = {\n isSuccess: false;\n isError: true;\n status: number;\n statusText: string;\n data: E;\n};\n\ntype ResponseWrapper<T, E> = SuccessResponseWrapper<T> | ErrorResponseWrapper<E>;\n\ntype CommonResponseType = {\n success: boolean;\n};\n\n/**\n *\n * @param pathOrUrl\n * @param data\n * @returns\n */\nexport async function post<\n ResponseType extends CommonResponseType = CommonResponseType,\n ErrorType = { error: string; error_description?: string },\n>(path: string, data: Record<string, unknown> | URLSearchParams, headers: Record<string, string> = {}) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), {\n method: \"POST\",\n headers: {\n \"Content-Type\":\n data instanceof URLSearchParams ? \"application/x-www-form-urlencoded\" : \"application/json\",\n ...headers,\n },\n body: data instanceof URLSearchParams ? data : JSON.stringify(data),\n }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nexport async function get<ResponseType = unknown, ErrorType = { error: string; error_description?: string }>(\n path: string,\n headers: Record<string, string> = {},\n) {\n if (accessStore.get(\"access_token\")) {\n headers.Authorization = `Bearer ${accessStore.get(\"access_token\")}`;\n }\n const response = await fetch(toURL(path), { headers, method: \"GET\" }).catch((error) => {\n logger.error(`Fatal Error requesting API: ${error.message} (${error.cause.code})`);\n logger.error(`Please check your internet connection and try again, or retry later.`);\n process.exit(1);\n });\n return formatResponse<ResponseType, ErrorType>(response);\n}\n\nfunction toURL(path: string) {\n const apiBaseURL = new URL(API_BASE_URL.endsWith(\"/\") ? API_BASE_URL : `${API_BASE_URL}/`);\n return new URL(path, apiBaseURL);\n}\n\nasync function formatResponse<SuccessType, ErrorType>(\n response: Response,\n): Promise<ResponseWrapper<SuccessType, ErrorType>> {\n const data = response.headers.get(\"content-type\")?.startsWith(\"application/json\")\n ? ((await response.json()) as ResponseType)\n : ((await response.text()) as ResponseType);\n\n if (response.ok) {\n return {\n isSuccess: true,\n isError: false,\n status: response.status,\n statusText: response.statusText,\n data: data as SuccessType,\n };\n } else {\n return {\n isSuccess: false,\n isError: true,\n status: response.status,\n statusText: response.statusText,\n data: data as ErrorType,\n };\n }\n}\n","import { resolve } from \"node:path\";\nimport { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport chalk from \"chalk\";\nimport type { CommandArgOpts } from \"../../types\";\nimport { formatAPIError, getPackageManager } from \"../../utils\";\nimport { getTokenOrThrow } from \"../../store\";\nimport { uploadTemplate } from \"./uploader\";\nimport path from \"node:path\";\nimport { post } from \"../../api\";\nimport { API_ENDPOINT_REGISTER_TEMPLATE } from \"../../constants\";\nimport { loadConfigFromJsFile, validateTemplateConfig } from \"~/node/shared/config\";\nimport { isLoggedIn } from \"../../is-logged-in\";\n\nexport async function publish({ options, args, logger }: CommandArgOpts) {\n // check if user is logged in\n if (!(await isLoggedIn(true))) {\n const pkgCmd = getPackageManager();\n logger.error(\n ` ${chalk.redBright(\"Error\")}: User token not found. Please run ${chalk.cyan(`${pkgCmd} run enpage:login`)} to authenticate or set the ${chalk.cyan(\"ENPAGE_API_TOKEN\")} environment variable.\\n`,\n );\n process.exit(1);\n }\n\n const templateDir = args.length\n ? path.isAbsolute(args[0])\n ? args[0]\n : resolve(process.cwd(), args[0])\n : process.cwd();\n\n if (!existsSync(templateDir)) {\n logger.error(` Template directory not found: ${templateDir}. Aborting.\\n`);\n process.exit(1);\n }\n\n const distDir =\n args.length > 1\n ? path.isAbsolute(args[1])\n ? args[1]\n : resolve(process.cwd(), args[1])\n : resolve(templateDir, \"dist\");\n\n if (!existsSync(distDir)) {\n logger.error(\n ` Dist directory not found: ${distDir}.\\n Please run 'build' before publishing. Aborting.\\n`,\n );\n process.exit(1);\n }\n\n // check if enpage.config.js and package.json exist in the current directory\n // if not, exit with an error\n if (!existsSync(resolve(templateDir, \"enpage.config.js\"))) {\n logger.error(\n ` ${chalk.redBright(\"Error\")}: file enpage.config.js not found in ${templateDir}. Aborting.\\n`,\n );\n process.exit(1);\n }\n\n // load manifest from both enpage.config.js and package.json\n // manifest.json is used to store the template ID for future updates\n const config = await loadConfigFromJsFile(resolve(templateDir, \"enpage.config.js\"), logger);\n\n validateTemplateConfig(config, logger);\n\n const token = getTokenOrThrow();\n const pkgLocation = getPackageLocation(templateDir);\n\n if (!pkgLocation) {\n logger.error(` ${chalk.redBright(\"Error\")}: package.json file not found in ${templateDir}. Aborting.\\n`);\n process.exit(1);\n }\n\n // load package.json to get the template ID (if it exists)\n const pkg = await getPackageJsonContents(pkgLocation);\n\n if (!pkg) {\n logger.error(\n ` ${chalk.redBright(\"Error\")}: cannot read/parse package.json file in ${templateDir}. Aborting.\\n`,\n );\n process.exit(1);\n }\n\n if (!pkg.enpage?.id) {\n // call API to create a new template\n const { data, isError, status } = await post<{ success: true; template: { id: string } }>(\n API_ENDPOINT_REGISTER_TEMPLATE,\n {}, // todo: fill with template data\n );\n if (isError) {\n logger.error(` ${chalk.redBright(\"Error\")}: Cannot register template: ${formatAPIError(data)}\\n`);\n process.exit(1);\n }\n pkg.enpage ??= {};\n pkg.enpage.id = data.template.id;\n\n // save the template ID to package.json\n try {\n if (!options.dryRun) writeFileSync(pkgLocation, JSON.stringify(pkg, null, 2));\n } catch (e) {\n logger.error(\n ` ${chalk.redBright(\"Error\")}: Cannot update template id in package.json file located in ${templateDir}. Aborting.\\n`,\n );\n process.exit(1);\n }\n }\n\n const templateId = pkg.enpage.id;\n\n // submit template to Enpage\n logger.info(`Submitting template to Enpage...\\n`);\n\n const uploadResults = await uploadTemplate(templateId, templateDir, token, options.dryRun);\n\n if (!uploadResults.success) {\n logger.error(\"\\nUpload failed. See details above.\\n\");\n process.exit(1);\n }\n\n logger.success(`Template ${templateId} published.\\n`);\n}\n\nfunction getPackageLocation(templateDir: string) {\n return existsSync(resolve(templateDir, \"package.json\"))\n ? resolve(templateDir, \"package.json\")\n : existsSync(resolve(templateDir, \"template-package.json\"))\n ? resolve(templateDir, \"template-package.json\")\n : false;\n}\n\nfunction getPackageJsonContents(pkgJsonPath: string) {\n try {\n return JSON.parse(readFileSync(pkgJsonPath, \"utf-8\"));\n } catch (e) {\n return null;\n }\n}\n","import path from \"node:path\";\nimport fs from \"node:fs\";\nimport crypto from \"node:crypto\";\nimport fg from \"fast-glob\";\nimport { API_BASE_URL, DEFAULT_UPLOAD_MAX_CONCURRENCY } from \"../../constants\";\nimport http from \"node:http\";\nimport https from \"node:https\";\nimport { pipeline } from \"node:stream\";\nimport type { GenericApiError } from \"../../types\";\nimport { logger } from \"~/node/shared/logger\";\nimport chalk from \"chalk\";\nimport FormData from \"form-data\";\nimport parseGitIgnore from \"./parse-gitignore\";\nimport PQueue from \"p-queue\";\nimport ora from \"ora\";\nimport { customAlphabet } from \"nanoid\";\nimport { post } from \"../../api\";\n\ninterface UploadStats {\n fileName: string;\n fileSize: number;\n uploadDuration: number;\n statusCode: number;\n serverResponse: string;\n}\n\nclass UploadError extends Error implements GenericApiError {\n constructor(\n public error: string,\n public error_description: string,\n public filename: string,\n ) {\n super(`${error}: ${error_description}`);\n this.name = \"UploadError\";\n }\n}\n\ninterface UploadConfig {\n maxDataSize: number;\n retryAttempts: number;\n retryDelay: number;\n}\n\nconst defaultConfig: UploadConfig = {\n maxDataSize: 12 * 1024 * 1024, // 12MB\n retryAttempts: 2,\n retryDelay: 1000,\n};\n\nconst agent = new http.Agent({\n keepAlive: true,\n maxSockets: 10,\n keepAliveMsecs: 3000, // Keep connections open for 3 seconds\n});\n\nasync function discoverFiles(templateDir: string): Promise<string[]> {\n const gitignore = path.join(templateDir, \".gitignore\");\n const gitignoreExists = fs.existsSync(gitignore);\n const gitignored = gitignoreExists ? parseGitIgnore(fs.readFileSync(gitignore, \"utf-8\")).patterns : [];\n\n return fg(\"**/*\", {\n cwd: templateDir,\n onlyFiles: true,\n dot: true,\n absolute: true,\n ignore: [\n \"node_modules/**\",\n \".cache/**\",\n \"**/.DS_Store\",\n \".gitignore\",\n \".env\",\n \".env.*\",\n \".git/**\",\n \"dist/**\",\n ...gitignored,\n ],\n });\n}\n\nasync function uploadFile(\n filePath: string,\n relativePath: string,\n uploadUrl: string,\n templateId: string,\n spinner: ReturnType<typeof ora>,\n token: string,\n config: UploadConfig,\n): Promise<UploadStats> {\n const uploadWithRetry = async (attempt: number): Promise<UploadStats> => {\n try {\n return await performUpload(filePath, relativePath, uploadUrl, templateId, spinner, token, config);\n } catch (error) {\n if (attempt < config.retryAttempts) {\n logger.warn(`Retrying upload for ${relativePath} (attempt ${attempt + 1})`);\n await new Promise((resolve) => setTimeout(resolve, config.retryDelay));\n return uploadWithRetry(attempt + 1);\n }\n throw error;\n }\n };\n\n return uploadWithRetry(0);\n}\n\nasync function performUpload(\n filePath: string,\n relativePath: string,\n uploadUrl: string,\n templateId: string,\n spinner: ReturnType<typeof ora>,\n token: string,\n config: UploadConfig,\n): Promise<UploadStats> {\n return new Promise<UploadStats>((resolve, reject) => {\n const stats = fs.statSync(filePath);\n const fileName = path.basename(filePath);\n const startTime = Date.now();\n\n const form = new FormData({\n maxDataSize: config.maxDataSize,\n });\n const fileStream = fs.createReadStream(filePath);\n let totalUploaded = 0;\n\n const updateProgress = (chunk: Buffer | string) => {\n totalUploaded += chunk.length;\n };\n\n fileStream.on(\"data\", updateProgress);\n form.append(\"file\", fileStream, {\n filename: fileName,\n knownLength: stats.size,\n });\n\n const options: https.RequestOptions = {\n agent,\n method: \"POST\",\n headers: {\n authorization: `Bearer ${token}`,\n \"x-upstart-template-file-path\": relativePath,\n \"x-upstart-template-id\": templateId,\n ...form.getHeaders(),\n },\n };\n\n const protocol = uploadUrl.startsWith(\"https\") ? https : http;\n const req = protocol.request(uploadUrl, options, (res) => {\n let responseBody = \"\";\n res.on(\"data\", (chunk) => {\n responseBody += chunk;\n });\n\n res.on(\"end\", () => {\n const endTime = Date.now();\n const uploadStats: UploadStats = {\n fileName,\n fileSize: stats.size,\n uploadDuration: endTime - startTime,\n statusCode: res.statusCode ?? 0,\n serverResponse: responseBody,\n };\n\n if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {\n spinner.text = `Uploaded ${relativePath}`;\n resolve(uploadStats);\n } else {\n let errorObject: UploadError;\n if (res.headers[\"content-type\"]?.startsWith(\"application/json\")) {\n const parsedError = JSON.parse(responseBody);\n errorObject = new UploadError(\n parsedError.error || \"unknown_error\",\n parsedError.error_description || \"Unknown error occurred\",\n relativePath,\n );\n } else {\n errorObject = new UploadError(\n \"unknown_error\",\n responseBody || \"Unknown error occurred\",\n relativePath,\n );\n }\n\n spinner.fail(\n `Failed to upload ${relativePath} [${errorObject.error}] ${errorObject.error_description}`,\n );\n\n reject(errorObject);\n }\n });\n });\n\n req.on(\"error\", (error) => {\n reject(new UploadError(\"request_error\", error.message, relativePath));\n });\n\n pipeline(form, req, (err) => {\n if (err) {\n reject(\n new UploadError(\"pipeline_error\", `Pipeline failed for ${fileName}: ${err.message}`, relativePath),\n );\n }\n });\n });\n}\n\nfunction reportUploadStatistics(\n templateId: string,\n uploadedFiles: UploadStats[],\n failedFiles: PromiseRejectedResult[],\n) {\n if (failedFiles.length > 0) {\n logger.error(chalk.red(`Failed to upload ${failedFiles.length} files:`));\n failedFiles.forEach((failure) => {\n const error = failure.reason as UploadError;\n logger.error(`- ${error.filename}: ${error.error_description} (${error.error})`);\n });\n } else {\n logger.info(\n chalk.green(`Uploaded ${uploadedFiles.length} files successfully for template ${templateId}.\\n`),\n );\n }\n}\n\nexport async function uploadTemplate(\n templateId: string,\n templateDir: string,\n token: string,\n dryRun = false,\n config: Partial<UploadConfig> = {},\n) {\n const fullConfig = { ...defaultConfig, ...config };\n const queue = new PQueue({ concurrency: DEFAULT_UPLOAD_MAX_CONCURRENCY });\n const files = await discoverFiles(templateDir);\n const filesCount = files.length;\n const signatures: Record<string, string> = {};\n // generate a upload id\n const uploadId = generateUploadId();\n let completedUploads = 0;\n\n // compute signatures\n for (const file of files) {\n const relativePath = path.relative(templateDir, file);\n const md5 = await sha1sum(file);\n signatures[relativePath] = md5;\n }\n\n if (dryRun) {\n logger.info(\"Dry run mode enabled. Skipping upload.\\n\");\n logger.info(\"The following files would have been uploaded:\");\n files.forEach((file) => logger.info(`- ${file}`));\n process.exit(0);\n }\n\n const spinner = ora(`Uploading ${filesCount} files...`).start();\n\n // upload files\n const uploadPromises = files.map((file) => {\n const fullPath = path.resolve(templateDir, file);\n const relativePath = path.relative(templateDir, file);\n const url = `${API_BASE_URL}/v1/templates/${templateId}/upload/${uploadId}`;\n return queue.add(async () => {\n const result = await uploadFile(fullPath, relativePath, url, templateId, spinner, token, fullConfig);\n completedUploads++;\n return result;\n });\n });\n\n const results = await Promise.allSettled(uploadPromises);\n spinner.stop();\n\n const uploadedFiles = results.filter(\n (result): result is PromiseFulfilledResult<UploadStats> => result.status === \"fulfilled\",\n );\n\n const failedFiles = results.filter(\n (result): result is PromiseRejectedResult => result.status === \"rejected\",\n );\n\n reportUploadStatistics(\n templateId,\n uploadedFiles.map((r) => r.value),\n failedFiles,\n );\n\n // finalize upload\n if (!failedFiles.length && uploadedFiles.length) {\n const finalizeUrl = `${API_BASE_URL}/v1/templates/${templateId}/upload/${uploadId}/finalize`;\n const finalizePayload = {\n signatures,\n };\n\n const finalizeResponse = await post(finalizeUrl, finalizePayload);\n\n if (finalizeResponse.isError) {\n logger.error(\n `Failed to finalize upload: ${finalizeResponse.data.error_description} (${finalizeResponse.data.error})`,\n );\n return {\n filesCount,\n uploadedFiles: uploadedFiles.map((r) => r.value),\n failedFiles: [],\n success: false,\n };\n }\n }\n\n return {\n filesCount,\n uploadedFiles: uploadedFiles.map((r) => r.value),\n failedFiles,\n success: failedFiles.length === 0,\n };\n}\n\nasync function sha1sum(filePath: string): Promise<string> {\n const hash = await crypto.subtle.digest(\"SHA-1\", fs.readFileSync(filePath));\n // convert arrayBuffer to hex\n return Array.from(new Uint8Array(hash))\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n\nfunction generateUploadId(): string {\n const randomId = customAlphabet(\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\", 5);\n const now = new Date();\n const year = now.getUTCFullYear();\n const month = (now.getUTCMonth() + 1).toString().padStart(2, \"0\");\n const day = now.getUTCDate().toString().padStart(2, \"0\");\n const hours = now.getUTCHours().toString().padStart(2, \"0\");\n const minutes = now.getUTCMinutes().toString().padStart(2, \"0\");\n const seconds = now.getUTCSeconds().toString().padStart(2, \"0\");\n return `${year}${month}${day}${hours}${minutes}${seconds}_${randomId()}`;\n}\n","/*!\n * parse-gitignore <https://github.com/jonschlinkert/parse-gitignore>\n * Copyright (c) 2015-present, Jon Schlinkert.\n * Released under the MIT License.\n *\n * Converted to typescript by Matthias E. <matthias@upstart.gg>\n */\n\nimport * as fs from \"node:fs\";\n\n// eslint-disable-next-line no-control-regex\nconst INVALID_PATH_CHARS_REGEX = /[<>\"|?*\\n\\r\\t\\f\\x00-\\x1F]/;\nconst GLOBSTAR_REGEX = /(?:^|\\/)[*]{2}($|\\/)/;\nconst MAX_PATH_LENGTH = 260 - 12;\n\ninterface ParseOptions {\n path?: string;\n dedupe?: boolean;\n unique?: boolean;\n ignore?: string[];\n unignore?: string[];\n format?: boolean;\n formatSection?: (section: Section) => string;\n}\n\ninterface Section {\n name: string;\n comment?: string;\n patterns: string[];\n}\n\ninterface ParsedGitignore {\n sections: Section[];\n patterns: string[];\n path?: string;\n input: Buffer;\n format: (opts?: ParseOptions) => string;\n dedupe: (opts?: ParseOptions) => ParsedGitignore;\n globs: (opts?: ParseOptions) => GlobResult[];\n}\n\ninterface GlobResult {\n type: \"ignore\" | \"unignore\";\n path: string | null;\n patterns: string[];\n index: number;\n}\n\nconst isObject = (v: unknown): v is Record<string, unknown> =>\n v !== null && typeof v === \"object\" && !Array.isArray(v);\n\nconst isValidPath = (input: unknown): input is string =>\n typeof input === \"string\" && input.length <= MAX_PATH_LENGTH && !INVALID_PATH_CHARS_REGEX.test(input);\n\nconst split = (str: string): string[] => str.split(/\\r\\n?|\\n/);\nconst isComment = (str: string): boolean => str.startsWith(\"#\");\nconst isParsed = (input: unknown): input is ParsedGitignore =>\n isObject(input) && Array.isArray(input.patterns) && Array.isArray(input.sections);\n\nconst patterns = (input: string): string[] =>\n split(input)\n .map((l) => l.trim())\n .filter((line) => line !== \"\" && !isComment(line));\n\nconst parse = (input: string | ParsedGitignore, options: ParseOptions = {}): ParsedGitignore => {\n let filepath = options.path;\n\n if (isParsed(input)) return input;\n if (isValidPath(input) && fs.existsSync(input)) {\n filepath = input;\n input = fs.readFileSync(input, \"utf8\");\n }\n\n const lines = split(input);\n const names = new Map<string, Section>();\n\n let parsed: ParsedGitignore = { sections: [], patterns: [] } as unknown as ParsedGitignore;\n let section: Section = { name: \"default\", patterns: [] };\n let prev: Section | null = null;\n\n for (const line of lines) {\n const value = line.trim();\n\n if (value.startsWith(\"#\")) {\n const [, name] = /^#+\\s*(.*)\\s*$/.exec(value) || [];\n\n if (prev) {\n names.delete(prev.name);\n prev.comment = prev.comment ? `${prev.comment}\\n${value}` : value;\n prev.name = name ? `${prev.name.trim()}\\n${name.trim()}` : prev.name.trim();\n names.set(prev.name.toLowerCase().trim(), prev);\n continue;\n }\n\n section = { name: name?.trim() || \"\", comment: value, patterns: [] };\n names.set(section.name.toLowerCase(), section);\n parsed.sections.push(section);\n prev = section;\n continue;\n }\n\n if (value !== \"\") {\n section.patterns.push(value);\n parsed.patterns.push(value);\n }\n\n prev = null;\n }\n\n if (options.dedupe === true || options.unique === true) {\n parsed = dedupe(parsed, { ...options, format: false });\n }\n\n parsed.path = filepath;\n parsed.input = Buffer.from(input);\n parsed.format = (opts?: ParseOptions) => format(parsed, { ...options, ...opts });\n parsed.dedupe = (opts?: ParseOptions) => dedupe(parsed, { ...options, ...opts });\n parsed.globs = (opts?: ParseOptions) => globs(parsed, { path: filepath, ...options, ...opts });\n return parsed;\n};\n\nconst parseFile = (filepath: string, options?: ParseOptions): ParsedGitignore =>\n parse(fs.readFileSync(filepath, \"utf8\"), options);\n\nconst dedupe = (input: string | ParsedGitignore, options: ParseOptions): ParsedGitignore => {\n const parsed = parse(input, { ...options, dedupe: false });\n\n const names = new Map<string, Section>();\n const res: ParsedGitignore = { sections: [], patterns: [] } as unknown as ParsedGitignore;\n let current: Section;\n\n // first, combine duplicate sections\n for (const section of parsed.sections) {\n const { name = \"\", comment, patterns } = section;\n const key = name.trim().toLowerCase();\n\n for (const pattern of patterns) {\n if (!res.patterns.includes(pattern)) {\n res.patterns.push(pattern);\n }\n }\n\n if (name && names.has(key)) {\n current = names.get(key)!;\n current.patterns = [...current.patterns, ...patterns];\n } else {\n current = { name, comment, patterns };\n res.sections.push(current);\n names.set(key, current);\n }\n }\n\n // next, de-dupe patterns in each section\n for (const section of res.sections) {\n section.patterns = [...new Set(section.patterns)];\n }\n\n return res;\n};\n\nconst glob = (pattern: string): string => {\n // Return if a glob pattern has already been specified for sub-directories\n if (GLOBSTAR_REGEX.test(pattern)) {\n return pattern;\n }\n\n // If there is a separator at the beginning or middle (or both) of the pattern,\n // then the pattern is relative to the directory level of the particular .gitignore\n // file itself. Otherwise the pattern may also match at any level below the\n // .gitignore level. relative paths only\n let relative = false;\n if (pattern.startsWith(\"/\")) {\n pattern = pattern.slice(1);\n relative = true;\n } else if (pattern.slice(1, pattern.length - 1).includes(\"/\")) {\n relative = true;\n }\n\n // If there is a separator at the end of the pattern then the pattern will only match directories.\n pattern += pattern.endsWith(\"/\") ? \"**/\" : \"/**\";\n\n // If not relative, the pattern can match any files and directories.\n return relative ? pattern : `**/${pattern}`;\n};\n\nconst globs = (input: string | ParsedGitignore, options: ParseOptions = {}): GlobResult[] => {\n const parsed = parse(input, options);\n const result: GlobResult[] = [];\n let index = 0;\n\n const globPatterns = parsed.patterns\n .concat(options.ignore || [])\n .concat((options.unignore || []).map((p) => (!p.startsWith(\"!\") ? `!${p}` : p)));\n\n const push = (prefix: string, pattern: string) => {\n const prev = result[result.length - 1];\n const type = prefix ? \"unignore\" : \"ignore\";\n\n if (prev && prev.type === type) {\n if (!prev.patterns.includes(pattern)) {\n prev.patterns.push(pattern);\n }\n } else {\n result.push({ type, path: options.path || null, patterns: [pattern], index });\n index++;\n }\n };\n\n for (let pattern of globPatterns) {\n let prefix = \"\";\n\n // An optional prefix \"!\" which negates the pattern; any matching file excluded by\n // a previous pattern will become included again\n if (pattern.startsWith(\"!\")) {\n pattern = pattern.slice(1);\n prefix = \"!\";\n }\n\n // add the raw pattern to the results\n push(prefix, pattern.startsWith(\"/\") ? pattern.slice(1) : pattern);\n\n // add the glob pattern to the results\n push(prefix, glob(pattern));\n }\n\n return result;\n};\n\n/**\n * Formats a .gitignore section\n */\nconst formatSection = (section: Section = { name: \"\", patterns: [] }): string => {\n const output = [section.comment || \"\"];\n\n if (section.patterns?.length) {\n output.push(section.patterns.join(\"\\n\"));\n output.push(\"\");\n }\n\n return output.join(\"\\n\");\n};\n\n/**\n * Format a .gitignore file from the given input or object from `.parse()`.\n * @param {String | ParsedGitignore} input File path or contents.\n * @param {ParseOptions} options\n * @return {String} Returns formatted string.\n * @api public\n */\nconst format = (input: string | ParsedGitignore, options: ParseOptions = {}): string => {\n const parsed = parse(input, options);\n\n const fn = options.formatSection || formatSection;\n const sections = parsed.sections || parsed;\n const output: string[] = [];\n\n for (const section of ([] as Section[]).concat(sections)) {\n output.push(fn(section));\n }\n\n return output.join(\"\\n\");\n};\n\nexport {\n parse,\n parseFile,\n dedupe,\n format,\n globs,\n formatSection,\n patterns,\n type ParseOptions,\n type Section,\n type ParsedGitignore,\n type GlobResult,\n};\n\nexport default parse;\n","import fs from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport fg from \"fast-glob\";\nimport { type Logger, logger as defaultLogger } from \"./logger\";\nimport { basename, dirname, extname } from \"node:path\";\nimport type { SiteAndPagesConfig } from \"~/shared/site\";\n\nexport async function loadConfigFromJsFile(\n configPath: string,\n logger = defaultLogger as Logger,\n): Promise<SiteAndPagesConfig> {\n if (!fs.existsSync(configPath)) {\n logger.error(\n \"🔴 No enpage.config.js found!\\nYour project must have an enpage.config.js file in the root directory.\\n\\n\",\n );\n process.exit(1);\n }\n const config = (await import(configPath)) as SiteAndPagesConfig;\n\n // Parse the readme files fro the same directory as the config file\n const readmePath = dirname(configPath);\n const readme: Record<string, string> = {};\n const readmeFiles = await fg([\"README.enpage.md\", \"README.enpage.*.md\"], {\n cwd: readmePath,\n onlyFiles: true,\n absolute: true,\n caseSensitiveMatch: false,\n });\n\n for (const file of readmeFiles) {\n const base = basename(file, \".md\");\n const ext = extname(base);\n const language = (ext === \".enpage\" ? \"en\" : ext.substring(1)).toLowerCase();\n logger.debug(`Found template readme file (${language}): ${basename(file)}`);\n readme[language] = await readFile(file, \"utf-8\");\n }\n\n return config;\n}\n\nexport function loadConfigFromManifestFile(manifestPath: string, logger: Logger): SiteAndPagesConfig {\n if (!fs.existsSync(manifestPath)) {\n logger.error(\"🔴 No enpage.manifest.json found!\\nYou may want to 'build' your template.\\n\\n\");\n process.exit(1);\n }\n return JSON.parse(fs.readFileSync(manifestPath, \"utf-8\"));\n}\n\nexport function validateTemplateConfig(config: SiteAndPagesConfig, logger: Logger) {\n for (const key in config.site.datasources) {\n if (config.site.datasources[key].provider === \"http-json\" && !config.site.datasources[key].sampleData) {\n logger.error(\n `🔴 Error: Datasource \"${key}\" is missing sample data - nothing will be rendered during development! Please check your enpage.config.js file and add a \"sampleData\" key to your ${key} datasource.`,\n );\n throw new Error(`Missing sample data for datasource \"${key}\"`);\n }\n }\n\n // Todo: replace validation from zod to ajv\n // const validated = manifestSchema.safeParse(config.manifest);\n // if (!validated.success) {\n // logger.error(`🔴 Error: template manifest is invalid. Check your call to defineManifest().\\n`);\n // const err = fromError(validated.error);\n // logger.error(`Hint: ${err.toString()}\\n\\n`);\n // process.exit(1);\n // }\n\n return config;\n}\n","import { OAUTH_ENDPOINT_USER_INFO } from \"./constants\";\nimport { accessStore } from \"./store\";\n\nexport async function isLoggedIn(checkRemote = false): Promise<boolean> {\n const token = accessStore.get(\"access_token\");\n const expiration = accessStore.get(\"expires_at\");\n\n if (!token) {\n return false;\n }\n\n if (expiration && expiration < Date.now()) {\n console.log(\"Seems like your token expired...\");\n return false;\n }\n\n if (!checkRemote) {\n return true;\n }\n\n // Check if token is valid\n\n // import dynamically \"./api\" to avoid circular dependency\n const { get } = await import(\"./api\");\n const { isSuccess } = await get(OAUTH_ENDPOINT_USER_INFO);\n\n return isSuccess;\n}\n"],"mappings":";;gIAAO,SAASA,G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CAAC,+DAA+DC,CAAW;AAAA,CACzG,EACA,QAAQ,KAAK,CAAC,CAChB,CACF,CAEA,IAAMqB,EAAaT,EAAI,OAAO,GAG9BjB,EAAO,KAAK;AAAA,CAAoC,GAE1B,MAAM2B,GAAeD,EAAYrB,EAAaQ,EAAOf,EAAQ,MAAM,GAEtE,UACjBE,EAAO,MAAM;AAAA;AAAA,CAAuC,EACpD,QAAQ,KAAK,CAAC,GAGhBA,EAAO,QAAQ,YAAY0B,CAAU;AAAA,CAAe,CACtD,CAEA,SAASV,GAAmBX,EAAqB,CAC/C,OAAOG,EAAWD,EAAQF,EAAa,cAAc,CAAC,EAClDE,EAAQF,EAAa,cAAc,EACnCG,EAAWD,EAAQF,EAAa,uBAAuB,CAAC,EACtDE,EAAQF,EAAa,uBAAuB,EAC5C,EACR,CAEA,SAASa,GAAuBU,EAAqB,CACnD,GAAI,CACF,OAAO,KAAK,MAAMC,GAAaD,EAAa,OAAO,CAAC,CACtD,MAAY,CACV,OAAO,IACT,CACF","names":["getPackageManager","packageManager","pmPart","formatAPIError","error","init_utils","__esmMin","CLI_PROJECT_NAME","CLI_LOGIN_CLIENT_ID","API_BASE_URL","EDITOR_BASE_URL","DEFAULT_UPLOAD_MAX_CONCURRENCY","OAUTH_ENDPOINT_USER_INFO","API_ENDPOINT_REGISTER_TEMPLATE","init_constants","__esmMin","Conf","path","crypto","fs","fileURLToPath","chalk","getTokenOrThrow","token","accessStore","pkgCmd","getPackageManager","findNearestNodeModules","currentDir","__dirname","nodeModulesPath","getKey","tmpSecureStoreDir","keyPath","key","init_store","__esmMin","init_constants","init_utils","CLI_PROJECT_NAME","createLoggerBase","chalk","createLogger","level","allowClearScreen","showVersion","logger","VERSION","message","options","init_logger","__esmMin","api_exports","__export","get","post","path","data","headers","accessStore","response","toURL","error","logger","formatResponse","apiBaseURL","API_BASE_URL","init_api","__esmMin","init_logger","init_constants","init_store","init_utils","init_store","resolve","existsSync","readFileSync","writeFileSync","chalk","init_constants","init_logger","path","fs","crypto","fg","http","https","pipeline","chalk","FormData","fs","INVALID_PATH_CHARS_REGEX","GLOBSTAR_REGEX","MAX_PATH_LENGTH","isObject","v","isValidPath","input","split","str","isParsed","input","isObject","parse","input","options","filepath","isParsed","isValidPath","lines","split","names","parsed","section","prev","line","value","name","dedupe","opts","format","globs","dedupe","input","options","parsed","parse","names","res","current","section","name","comment","patterns","key","pattern","glob","GLOBSTAR_REGEX","relative","globs","result","index","globPatterns","p","push","prefix","prev","type","formatSection","output","format","fn","sections","parse_gitignore_default","parse","init_api","PQueue","ora","customAlphabet","UploadError","error","error_description","filename","defaultConfig","agent","http","discoverFiles","templateDir","gitignore","path","gitignored","fs","parse_gitignore_default","fg","uploadFile","filePath","relativePath","uploadUrl","templateId","spinner","token","config","uploadWithRetry","attempt","performUpload","logger","resolve","reject","stats","fileName","startTime","form","FormData","fileStream","totalUploaded","updateProgress","chunk","options","req","https","res","responseBody","endTime","uploadStats","errorObject","parsedError","pipeline","err","reportUploadStatistics","uploadedFiles","failedFiles","chalk","failure","uploadTemplate","dryRun","fullConfig","queue","DEFAULT_UPLOAD_MAX_CONCURRENCY","files","filesCount","signatures","uploadId","generateUploadId","completedUploads","file","md5","sha1sum","uploadPromises","fullPath","url","API_BASE_URL","result","results","r","finalizeUrl","finalizeResponse","post","hash","crypto","b","randomId","now","year","month","day","hours","minutes","seconds","init_api","init_constants","path","init_logger","fs","readFile","fg","basename","dirname","extname","loadConfigFromJsFile","configPath","logger","config","readmePath","readme","readmeFiles","file","base","ext","language","validateTemplateConfig","config","logger","key","init_constants","init_store","isLoggedIn","checkRemote","token","accessStore","expiration","get","isSuccess","OAUTH_ENDPOINT_USER_INFO","publish","options","args","logger","isLoggedIn","pkgCmd","getPackageManager","chalk","templateDir","path","resolve","existsSync","distDir","config","loadConfigFromJsFile","validateTemplateConfig","token","getTokenOrThrow","pkgLocation","getPackageLocation","pkg","getPackageJsonContents","data","isError","status","post","API_ENDPOINT_REGISTER_TEMPLATE","formatAPIError","writeFileSync","templateId","uploadTemplate","pkgJsonPath","readFileSync"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*! Upstart.gg - Copyright (C) 2024 Flippable - https://github.com/upstart-gg/upstart/blob/main/LICENSE */
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
`)),{...i,success:(r,s)=>i.info(T.green(r),s),error:(r,s)=>i.error(T.red(r),s),warn:(r,s)=>i.warn(T.yellow(r),s),warnOnce:(r,s)=>i.warnOnce(T.yellow(r),s),debug:(r,s)=>{e==="debug"&&i.info(T.gray(r),s)}}}var
|
|
3
|
+
import x from"node:path";import A from"node:fs";import ge from"node:crypto";import de from"fast-glob";var N="upstart-cli";var Ae=process.env.PUBLIC_UPSTART_OAUTH_CLIENT_ID??"50000000-0000-0000-0000-000000000001",y=process.env.PUBLIC_UPSTART_API_BASE_URL??"https://api.upstart.gg",Oe=process.env.PUBLIC_UPSTART_EDITOR_BASE_URL??"https://upstart.gg",G=10;import W from"node:http";import fe from"node:https";import{pipeline as me}from"node:stream";import{createLogger as z}from"vite";import T from"chalk";var M=.1;function H(e,t,n=!1){let i=z(e==="debug"?"info":e,{prefix:"[upstart]",allowClearScreen:t});return n&&i.info(T.hex("#7270c6").bold(`\u{1F680} Upstart v${M}
|
|
4
|
+
`)),{...i,success:(r,s)=>i.info(T.green(r),s),error:(r,s)=>i.error(T.red(r),s),warn:(r,s)=>i.warn(T.yellow(r),s),warnOnce:(r,s)=>i.warnOnce(T.yellow(r),s),debug:(r,s)=>{e==="debug"&&i.info(T.gray(r),s)}}}var d=H();import B from"chalk";import ye from"form-data";import*as $ from"node:fs";var q=/[<>"|?*\n\r\t\f\x00-\x1F]/,V=/(?:^|\/)[*]{2}($|\/)/,X=248,J=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),K=e=>typeof e=="string"&&e.length<=X&&!q.test(e),Y=e=>e.split(/\r\n?|\n/);var Q=e=>J(e)&&Array.isArray(e.patterns)&&Array.isArray(e.sections);var b=(e,t={})=>{let n=t.path;if(Q(e))return e;K(e)&&$.existsSync(e)&&(n=e,e=$.readFileSync(e,"utf8"));let i=Y(e),r=new Map,s={sections:[],patterns:[]},c={name:"default",patterns:[]},o=null;for(let a of i){let p=a.trim();if(p.startsWith("#")){let[,u]=/^#+\s*(.*)\s*$/.exec(p)||[];if(o){r.delete(o.name),o.comment=o.comment?`${o.comment}
|
|
5
5
|
${p}`:p,o.name=u?`${o.name.trim()}
|
|
6
|
-
${u.trim()}`:o.name.trim(),r.set(o.name.toLowerCase().trim(),o);continue}c={name:u?.trim()||"",comment:p,patterns:[]},r.set(c.name.toLowerCase(),c),s.sections.push(c),o=c;continue}p!==""&&(c.patterns.push(p),s.patterns.push(p)),o=null}return(t.dedupe===!0||t.unique===!0)&&(s=
|
|
6
|
+
${u.trim()}`:o.name.trim(),r.set(o.name.toLowerCase().trim(),o);continue}c={name:u?.trim()||"",comment:p,patterns:[]},r.set(c.name.toLowerCase(),c),s.sections.push(c),o=c;continue}p!==""&&(c.patterns.push(p),s.patterns.push(p)),o=null}return(t.dedupe===!0||t.unique===!0)&&(s=D(s,{...t,format:!1})),s.path=n,s.input=Buffer.from(e),s.format=a=>re(s,{...t,...a}),s.dedupe=a=>D(s,{...t,...a}),s.globs=a=>ee(s,{path:n,...t,...a}),s};var D=(e,t)=>{let n=b(e,{...t,dedupe:!1}),i=new Map,r={sections:[],patterns:[]},s;for(let c of n.sections){let{name:o="",comment:a,patterns:p}=c,u=o.trim().toLowerCase();for(let S of p)r.patterns.includes(S)||r.patterns.push(S);o&&i.has(u)?(s=i.get(u),s.patterns=[...s.patterns,...p]):(s={name:o,comment:a,patterns:p},r.sections.push(s),i.set(u,s))}for(let c of r.sections)c.patterns=[...new Set(c.patterns)];return r},Z=e=>{if(V.test(e))return e;let t=!1;return e.startsWith("/")?(e=e.slice(1),t=!0):e.slice(1,e.length-1).includes("/")&&(t=!0),e+=e.endsWith("/")?"**/":"/**",t?e:`**/${e}`},ee=(e,t={})=>{let n=b(e,t),i=[],r=0,s=n.patterns.concat(t.ignore||[]).concat((t.unignore||[]).map(o=>o.startsWith("!")?o:`!${o}`)),c=(o,a)=>{let p=i[i.length-1],u=o?"unignore":"ignore";p&&p.type===u?p.patterns.includes(a)||p.patterns.push(a):(i.push({type:u,path:t.path||null,patterns:[a],index:r}),r++)};for(let o of s){let a="";o.startsWith("!")&&(o=o.slice(1),a="!"),c(a,o.startsWith("/")?o.slice(1):o),c(a,Z(o))}return i},te=(e={name:"",patterns:[]})=>{let t=[e.comment||""];return e.patterns?.length&&(t.push(e.patterns.join(`
|
|
7
7
|
`)),t.push("")),t.join(`
|
|
8
|
-
`)},
|
|
9
|
-
`)};var
|
|
10
|
-
`))}async function
|
|
11
|
-
`),
|
|
8
|
+
`)},re=(e,t={})=>{let n=b(e,t),i=t.formatSection||te,r=n.sections||n,s=[];for(let c of[].concat(r))s.push(i(c));return s.join(`
|
|
9
|
+
`)};var v=b;import Se from"p-queue";import he from"ora";import{customAlphabet as Pe}from"nanoid";import se from"conf";import L from"node:path";import oe from"node:crypto";import R from"node:fs";import{fileURLToPath as ne}from"node:url";import qe from"chalk";var ie=ne(new URL(".",import.meta.url)),ae=pe(),k=new se({projectName:N,encryptionKey:ae,clearInvalidConfig:!0});function ce(){let e=ie;for(;e!==L.parse(e).root;){let t=L.join(e,"node_modules");if(R.existsSync(t))return t;e=L.dirname(e)}return null}function pe(){let e=ce();if(!e)throw new Error("Could not find nearest node_modules directory.");let t=L.join(e,".enpage-tmp");R.existsSync(t)||R.mkdirSync(t,{recursive:!0,mode:448});let n=L.join(t,".enpage-key");if(!R.existsSync(n)){let r=oe.randomBytes(32).toString("hex");return R.writeFileSync(n,r,{mode:384}),r}return R.readFileSync(n,"utf8")}async function F(e,t,n={}){k.get("access_token")&&(n.Authorization=`Bearer ${k.get("access_token")}`);let i=await fetch(le(e),{method:"POST",headers:{"Content-Type":t instanceof URLSearchParams?"application/x-www-form-urlencoded":"application/json",...n},body:t instanceof URLSearchParams?t:JSON.stringify(t)}).catch(r=>{d.error(`Fatal Error requesting API: ${r.message} (${r.cause.code})`),d.error("Please check your internet connection and try again, or retry later."),process.exit(1)});return ue(i)}function le(e){let t=new URL(y.endsWith("/")?y:`${y}/`);return new URL(e,t)}async function ue(e){let t=e.headers.get("content-type")?.startsWith("application/json")?await e.json():await e.text();return e.ok?{isSuccess:!0,isError:!1,status:e.status,statusText:e.statusText,data:t}:{isSuccess:!1,isError:!0,status:e.status,statusText:e.statusText,data:t}}var E=class extends Error{constructor(n,i,r){super(`${n}: ${i}`);this.error=n;this.error_description=i;this.filename=r;this.name="UploadError"}},_e={maxDataSize:12*1024*1024,retryAttempts:2,retryDelay:1e3},Te=new W.Agent({keepAlive:!0,maxSockets:10,keepAliveMsecs:3e3});async function Re(e){let t=x.join(e,".gitignore"),i=A.existsSync(t)?v(A.readFileSync(t,"utf-8")).patterns:[];return de("**/*",{cwd:e,onlyFiles:!0,dot:!0,absolute:!0,ignore:["node_modules/**",".cache/**","**/.DS_Store",".gitignore",".env",".env.*",".git/**","dist/**",...i]})}async function Ee(e,t,n,i,r,s,c){let o=async a=>{try{return await we(e,t,n,i,r,s,c)}catch(p){if(a<c.retryAttempts)return d.warn(`Retrying upload for ${t} (attempt ${a+1})`),await new Promise(u=>setTimeout(u,c.retryDelay)),o(a+1);throw p}};return o(0)}async function we(e,t,n,i,r,s,c){return new Promise((o,a)=>{let p=A.statSync(e),u=x.basename(e),S=Date.now(),h=new ye({maxDataSize:c.maxDataSize}),O=A.createReadStream(e),C=0,P=l=>{C+=l.length};O.on("data",P),h.append("file",O,{filename:u,knownLength:p.size});let _={agent:Te,method:"POST",headers:{authorization:`Bearer ${s}`,"x-upstart-template-file-path":t,"x-upstart-template-id":i,...h.getHeaders()}},m=(n.startsWith("https")?fe:W).request(n,_,l=>{let f="";l.on("data",w=>{f+=w}),l.on("end",()=>{let w=Date.now(),j={fileName:u,fileSize:p.size,uploadDuration:w-S,statusCode:l.statusCode??0,serverResponse:f};if(l.statusCode&&l.statusCode>=200&&l.statusCode<300)r.text=`Uploaded ${t}`,o(j);else{let U;if(l.headers["content-type"]?.startsWith("application/json")){let I=JSON.parse(f);U=new E(I.error||"unknown_error",I.error_description||"Unknown error occurred",t)}else U=new E("unknown_error",f||"Unknown error occurred",t);r.fail(`Failed to upload ${t} [${U.error}] ${U.error_description}`),a(U)}})});m.on("error",l=>{a(new E("request_error",l.message,t))}),me(h,m,l=>{l&&a(new E("pipeline_error",`Pipeline failed for ${u}: ${l.message}`,t))})})}function Ue(e,t,n){n.length>0?(d.error(B.red(`Failed to upload ${n.length} files:`)),n.forEach(i=>{let r=i.reason;d.error(`- ${r.filename}: ${r.error_description} (${r.error})`)})):d.info(B.green(`Uploaded ${t.length} files successfully for template ${e}.
|
|
10
|
+
`))}async function ft(e,t,n,i=!1,r={}){let s={..._e,...r},c=new Se({concurrency:G}),o=await Re(t),a=o.length,p={},u=xe(),S=0;for(let g of o){let m=x.relative(t,g),l=await Le(g);p[m]=l}i&&(d.info(`Dry run mode enabled. Skipping upload.
|
|
11
|
+
`),d.info("The following files would have been uploaded:"),o.forEach(g=>d.info(`- ${g}`)),process.exit(0));let h=he(`Uploading ${a} files...`).start(),O=o.map(g=>{let m=x.resolve(t,g),l=x.relative(t,g),f=`${y}/v1/templates/${e}/upload/${u}`;return c.add(async()=>{let w=await Ee(m,l,f,e,h,n,s);return S++,w})}),C=await Promise.allSettled(O);h.stop();let P=C.filter(g=>g.status==="fulfilled"),_=C.filter(g=>g.status==="rejected");if(Ue(e,P.map(g=>g.value),_),!_.length&&P.length){let g=`${y}/v1/templates/${e}/upload/${u}/finalize`,l=await F(g,{signatures:p});if(l.isError)return d.error(`Failed to finalize upload: ${l.data.error_description} (${l.data.error})`),{filesCount:a,uploadedFiles:P.map(f=>f.value),failedFiles:[],success:!1}}return{filesCount:a,uploadedFiles:P.map(g=>g.value),failedFiles:_,success:_.length===0}}async function Le(e){let t=await ge.subtle.digest("SHA-1",A.readFileSync(e));return Array.from(new Uint8Array(t)).map(n=>n.toString(16).padStart(2,"0")).join("")}function xe(){let e=Pe("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",5),t=new Date,n=t.getUTCFullYear(),i=(t.getUTCMonth()+1).toString().padStart(2,"0"),r=t.getUTCDate().toString().padStart(2,"0"),s=t.getUTCHours().toString().padStart(2,"0"),c=t.getUTCMinutes().toString().padStart(2,"0"),o=t.getUTCSeconds().toString().padStart(2,"0");return`${n}${i}${r}${s}${c}${o}_${e()}`}export{ft as uploadTemplate};
|
|
12
12
|
/*!
|
|
13
13
|
* parse-gitignore <https://github.com/jonschlinkert/parse-gitignore>
|
|
14
14
|
* Copyright (c) 2015-present, Jon Schlinkert.
|