UNPKG

adastra-cli

Version:

Adastra CLI ✨ is a CLI toolkit built on top of Shopify CLI 3.X, this means that existing Adastra commands are the same as Shopify's. The goal from this package is to allow developers to use one CLI intefrace between the Vite and Shopify development server

71 lines (69 loc) 1.92 kB
import { detect_urls_default } from "../../chunk-3DTQEPMT.js"; import { BaseCommand } from "../../chunk-25HWKXJ7.js"; import { globalFlags, themeFlags } from "../../chunk-H7IKTGYJ.js"; import { log } from "../../chunk-BMW4AWX2.js"; // src/commands/preview/index.ts import { Flags } from "@oclif/core"; import { execa } from "execa"; import open from "open"; import { build } from "vite"; import { colored, loadWithRocketGradient } from "adastra-cli-kit"; var _Preview = class extends BaseCommand { async run() { const { flags } = await this.parse(_Preview); const command = ["theme", "open", ...this.passThroughFlags(flags)]; try { const opening = await loadWithRocketGradient("Opening a theme preview..."); await build({ logLevel: "silent" }); const { stdout } = await execa("shopify", command); const [, , previewURL] = detect_urls_default(stdout); if (previewURL) await open(previewURL); opening.text = colored(stdout); opening.succeed(); } catch (error) { log("error", error); this.exit(1); } } }; var Preview = _Preview; Preview.description = "Opens a preview of your remote development theme."; Preview.flags = { ...globalFlags, password: themeFlags.password, development: Flags.boolean({ char: "d", description: "Delete your development theme.", env: "SHOPIFY_FLAG_DEVELOPMENT", default: true }), editor: Flags.boolean({ char: "e", description: "Open the theme editor for the specified theme in the browser.", env: "SHOPIFY_FLAG_EDITOR" }), live: Flags.boolean({ char: "l", description: "Pull theme files from your remote live theme.", env: "SHOPIFY_FLAG_LIVE" }), theme: Flags.string({ char: "t", description: "Theme ID or name of the remote theme.", env: "SHOPIFY_FLAG_THEME_ID" }), store: themeFlags.store }; export { Preview as default };