@acidgreen-au/ag-cicd-cli 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cli.mjs +61 -67
  2. package/package.json +2 -2
package/dist/cli.mjs CHANGED
@@ -613,6 +613,64 @@ function commitMsg(options) {
613
613
  process.exit(0);
614
614
  }
615
615
 
616
+ //#endregion
617
+ //#region src/utils/shopify.ts
618
+ function listThemes() {
619
+ const result = execSync("shopify theme list --json", { encoding: "utf-8" });
620
+ return JSON.parse(result);
621
+ }
622
+ function findThemeByName(name) {
623
+ return listThemes().find((t) => t.name === name);
624
+ }
625
+ function findLiveTheme() {
626
+ return listThemes().find((t) => t.role === "live");
627
+ }
628
+ function duplicateTheme(themeId, name) {
629
+ const result = execSync(`shopify theme duplicate -j --theme "${themeId}" --name "${name}"`, { encoding: "utf-8" });
630
+ return JSON.parse(result);
631
+ }
632
+ function pushTheme(path, themeId, ignorePatterns = [], allowLive = false) {
633
+ const result = execSync(`shopify theme push --path ${path} --theme "${themeId}" ${ignorePatterns.map((p) => `--ignore "${path}/${p}"`).join(" ")}${allowLive ? " --allow-live" : ""} --json`, { encoding: "utf-8" });
634
+ return JSON.parse(result);
635
+ }
636
+ function deleteTheme(themeId) {
637
+ execSync(`shopify theme delete --theme "${themeId}" --force`, { encoding: "utf-8" });
638
+ }
639
+ function renameTheme(themeId, name) {
640
+ execSync(`shopify theme rename --theme "${themeId}" --name "${name}"`, { encoding: "utf-8" });
641
+ }
642
+ function writeDeployEnv(previewUrl, editorUrl, themeId, extras = {}) {
643
+ let content = `PREVIEW_URL=${previewUrl}\nEDITOR_URL=${editorUrl}\nTHEME_ID=${themeId}\n`;
644
+ for (const [key, value] of Object.entries(extras)) content += `${key}=${value}\n`;
645
+ writeFileSync("deploy.env", content);
646
+ }
647
+ const previewBranchName = (branch) => `AG Preview: ${branch}`.substring(0, 49);
648
+ function formatDeployThemeName(env, branch) {
649
+ const now = /* @__PURE__ */ new Date();
650
+ const parts = new Intl.DateTimeFormat("en-AU", {
651
+ timeZone: "Australia/Sydney",
652
+ year: "numeric",
653
+ month: "2-digit",
654
+ day: "2-digit",
655
+ hour: "2-digit",
656
+ minute: "2-digit",
657
+ hour12: false
658
+ }).formatToParts(now);
659
+ const get = (type) => parts.find((p) => p.type === type)?.value;
660
+ return `AG ${env} from ${branch} at ${`${get("year")}-${get("month")}-${get("day")}`} ${`${get("hour")}:${get("minute")}`}${(new Intl.DateTimeFormat("en-AU", {
661
+ timeZone: "Australia/Sydney",
662
+ timeZoneName: "shortOffset"
663
+ }).formatToParts(now).find((p) => p.type === "timeZoneName")?.value ?? "GMT+11").replace("GMT", "")}`.substring(0, 50);
664
+ }
665
+ const DEFAULT_IGNORES = [
666
+ "templates/**/*.json",
667
+ "locales/**/*.json",
668
+ "config/settings_data.json",
669
+ "src/*",
670
+ "public/*",
671
+ "assets/.vite"
672
+ ];
673
+
616
674
  //#endregion
617
675
  //#region src/commands/config-shopify.ts
618
676
  const helpText$7 = `
@@ -637,13 +695,6 @@ Examples:
637
695
  $ ag config:shopify production # Add production environment
638
696
  $ ag config:shopify staging --force # Overwrite staging environment
639
697
  $ ag config:shopify --store my-store.myshopify.com --theme 123456789`;
640
- const DEFAULT_IGNORES = [
641
- "templates/*.json",
642
- "locales/*.json",
643
- "config/settings_data.json",
644
- "src/*",
645
- "public/*"
646
- ];
647
698
  const DEFAULT_PATH = "theme";
648
699
  function register$7(program$1) {
649
700
  program$1.command("config:shopify").description("Create or update shopify.theme.toml configuration").addHelpText("after", helpText$7).argument("[name]", "Environment name (default: 'default')").option("-f, --force", "Overwrite existing environment").option("-s, --store <store>", "Store name (e.g., my-store.myshopify.com)").option("-t, --theme <themeId>", "Theme ID for deployment").option("-p, --preset <preset>", "Preset for default env: 'local' (default) or 'ci'").action(configShopify);
@@ -754,63 +805,6 @@ async function configShopify(name, options) {
754
805
  console.log(`\n${existsSync(configPath) ? "Updated" : "Created"} ${configPath} with '${envName}' environment`);
755
806
  }
756
807
 
757
- //#endregion
758
- //#region src/utils/shopify.ts
759
- function listThemes() {
760
- const result = execSync("shopify theme list --json", { encoding: "utf-8" });
761
- return JSON.parse(result);
762
- }
763
- function findThemeByName(name) {
764
- return listThemes().find((t) => t.name === name);
765
- }
766
- function findLiveTheme() {
767
- return listThemes().find((t) => t.role === "live");
768
- }
769
- function duplicateTheme(themeId, name) {
770
- const result = execSync(`shopify theme duplicate -j --theme "${themeId}" --name "${name}"`, { encoding: "utf-8" });
771
- return JSON.parse(result);
772
- }
773
- function pushTheme(path, themeId, ignorePatterns = [], allowLive = false) {
774
- const result = execSync(`shopify theme push --path ${path} --theme "${themeId}" ${ignorePatterns.map((p) => `--ignore "${p}"`).join(" ")}${allowLive ? " --allow-live" : ""} --json`, { encoding: "utf-8" });
775
- return JSON.parse(result);
776
- }
777
- function deleteTheme(themeId) {
778
- execSync(`shopify theme delete --theme "${themeId}" --force`, { encoding: "utf-8" });
779
- }
780
- function renameTheme(themeId, name) {
781
- execSync(`shopify theme rename --theme "${themeId}" --name "${name}"`, { encoding: "utf-8" });
782
- }
783
- function writeDeployEnv(previewUrl, editorUrl, themeId, extras = {}) {
784
- let content = `PREVIEW_URL=${previewUrl}\nEDITOR_URL=${editorUrl}\nTHEME_ID=${themeId}\n`;
785
- for (const [key, value] of Object.entries(extras)) content += `${key}=${value}\n`;
786
- writeFileSync("deploy.env", content);
787
- }
788
- const previewBranchName = (branch) => `AG Preview: ${branch}`.substring(0, 49);
789
- function formatDeployThemeName(env, branch) {
790
- const now = /* @__PURE__ */ new Date();
791
- const parts = new Intl.DateTimeFormat("en-AU", {
792
- timeZone: "Australia/Sydney",
793
- year: "numeric",
794
- month: "2-digit",
795
- day: "2-digit",
796
- hour: "2-digit",
797
- minute: "2-digit",
798
- hour12: false
799
- }).formatToParts(now);
800
- const get = (type) => parts.find((p) => p.type === type)?.value;
801
- return `AG ${env} from ${branch} at ${`${get("year")}-${get("month")}-${get("day")}`} ${`${get("hour")}:${get("minute")}`}${(new Intl.DateTimeFormat("en-AU", {
802
- timeZone: "Australia/Sydney",
803
- timeZoneName: "shortOffset"
804
- }).formatToParts(now).find((p) => p.type === "timeZoneName")?.value ?? "GMT+11").replace("GMT", "")}`.substring(0, 50);
805
- }
806
- const defaultIgnores = [
807
- "templates/**/*.json",
808
- "locales/**/*.json",
809
- "config/settings_data.json",
810
- "src/*",
811
- "public/*"
812
- ];
813
-
814
808
  //#endregion
815
809
  //#region src/commands/deploy.ts
816
810
  const helpText$6 = `
@@ -838,7 +832,7 @@ function register$6(program$1) {
838
832
  function deploy(options) {
839
833
  const { themeId, path, allowLive, env, branch } = options;
840
834
  const themeIdNum = parseInt(themeId, 10);
841
- const { preview_url, editor_url } = pushTheme(path, themeIdNum, defaultIgnores, allowLive).theme;
835
+ const { preview_url, editor_url } = pushTheme(path, themeIdNum, DEFAULT_IGNORES, allowLive).theme;
842
836
  console.log("Release deployed successfully!");
843
837
  console.log(`Preview URL: ${preview_url}`);
844
838
  console.log(`Editor URL: ${editor_url}`);
@@ -913,7 +907,7 @@ function deployReview(options) {
913
907
  }
914
908
  }
915
909
  console.log(`Deploying branch ${branch} to theme ID: ${reviewThemeId}`);
916
- const { preview_url, editor_url } = pushTheme(path, reviewThemeId, defaultIgnores).theme;
910
+ const { preview_url, editor_url } = pushTheme(path, reviewThemeId, DEFAULT_IGNORES).theme;
917
911
  console.log("Review app deployed successfully!");
918
912
  console.log(`Preview URL: ${preview_url}`);
919
913
  console.log(`Editor URL: ${editor_url}`);
@@ -994,7 +988,7 @@ function release(options) {
994
988
  if (!liveTheme) throw new Error("No live theme found to clone from");
995
989
  console.log(`Cloning from published theme ID: ${liveTheme.id}`);
996
990
  const releaseThemeId = duplicateTheme(liveTheme.id, themeName).theme.id;
997
- const { preview_url, editor_url } = pushTheme(path, releaseThemeId, defaultIgnores).theme;
991
+ const { preview_url, editor_url } = pushTheme(path, releaseThemeId, DEFAULT_IGNORES).theme;
998
992
  console.log("Release deployed successfully!");
999
993
  console.log(`Preview URL: ${preview_url}`);
1000
994
  console.log(`Editor URL: ${editor_url}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acidgreen-au/ag-cicd-cli",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Acidgreen CI/CD CLI tools",
5
5
  "type": "module",
6
6
  "bin": {
@@ -49,7 +49,7 @@
49
49
  "biome:check": "biome check",
50
50
  "biome:ci": "biome ci",
51
51
  "typecheck": "tsc",
52
- "precommit": "pnpm run biome:ci && pnpm run typecheck",
52
+ "precommit": "pnpm run biome:ci && pnpm run typecheck && pnpm run test:run",
53
53
  "changeset": "changeset"
54
54
  }
55
55
  }