@acidgreen-au/ag-cicd-cli 0.1.1 → 0.2.0
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/cli.mjs +81 -44
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -506,12 +506,17 @@ Details:
|
|
|
506
506
|
With a name argument: Adds a new named environment, copying path and
|
|
507
507
|
ignore settings from the default environment.
|
|
508
508
|
|
|
509
|
-
|
|
509
|
+
Presets (for default environment only):
|
|
510
|
+
- local: Full config with store and theme (default)
|
|
511
|
+
- ci: Minimal config with only path and ignore settings
|
|
512
|
+
|
|
513
|
+
Prompts for (unless provided via options or using 'ci' preset):
|
|
510
514
|
- Store name (required): Your myshopify.com store URL
|
|
511
515
|
- Theme ID (optional): Target theme ID for deployment
|
|
512
516
|
|
|
513
517
|
Examples:
|
|
514
|
-
$ ag config:shopify # Create
|
|
518
|
+
$ ag config:shopify # Create default with local preset
|
|
519
|
+
$ ag config:shopify --preset ci # Create default for CI (no store/theme)
|
|
515
520
|
$ ag config:shopify production # Add production environment
|
|
516
521
|
$ ag config:shopify staging --force # Overwrite staging environment
|
|
517
522
|
$ ag config:shopify --store my-store.myshopify.com --theme 123456789`;
|
|
@@ -524,7 +529,7 @@ const DEFAULT_IGNORES = [
|
|
|
524
529
|
];
|
|
525
530
|
const DEFAULT_PATH = "theme";
|
|
526
531
|
function register$7(program$1) {
|
|
527
|
-
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").action(configShopify);
|
|
532
|
+
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);
|
|
528
533
|
}
|
|
529
534
|
function loadConfig(configPath) {
|
|
530
535
|
if (!existsSync(configPath)) return { environments: {} };
|
|
@@ -560,9 +565,16 @@ function buildEnvConfig(config, response) {
|
|
|
560
565
|
if (response.themeId) envConfig.theme = response.themeId;
|
|
561
566
|
return envConfig;
|
|
562
567
|
}
|
|
568
|
+
function buildCiEnvConfig() {
|
|
569
|
+
return {
|
|
570
|
+
path: DEFAULT_PATH,
|
|
571
|
+
ignore: DEFAULT_IGNORES
|
|
572
|
+
};
|
|
573
|
+
}
|
|
563
574
|
async function configShopify(name, options) {
|
|
564
575
|
const configPath = "shopify.theme.toml";
|
|
565
576
|
let envName = name ?? "default";
|
|
577
|
+
const preset = options.preset ?? "local";
|
|
566
578
|
const config = loadConfig(configPath);
|
|
567
579
|
if (!config.environments) config.environments = {};
|
|
568
580
|
const validationError = validateConfig(config, envName, options);
|
|
@@ -585,35 +597,41 @@ async function configShopify(name, options) {
|
|
|
585
597
|
console.error(`Error: ${validationError.message}`);
|
|
586
598
|
process.exit(1);
|
|
587
599
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
600
|
+
let envConfig;
|
|
601
|
+
if (envName === "default" && preset === "ci") {
|
|
602
|
+
envConfig = buildCiEnvConfig();
|
|
603
|
+
console.log("Using CI preset (path and ignore only)");
|
|
604
|
+
} else {
|
|
605
|
+
const defaultEnv = config.environments.default;
|
|
606
|
+
let store = options.store;
|
|
607
|
+
let themeId = options.theme;
|
|
608
|
+
if (!store) store = (await prompts({
|
|
609
|
+
type: "text",
|
|
610
|
+
name: "store",
|
|
611
|
+
message: "Store name (e.g., my-store.myshopify.com)",
|
|
612
|
+
initial: defaultEnv?.store,
|
|
613
|
+
validate: (value) => value.length > 0 || "Store name is required"
|
|
614
|
+
}, { onCancel: () => {
|
|
615
|
+
console.log("\nCancelled.");
|
|
616
|
+
process.exit(0);
|
|
617
|
+
} })).store;
|
|
618
|
+
if (themeId === void 0) themeId = (await prompts({
|
|
619
|
+
type: "text",
|
|
620
|
+
name: "themeId",
|
|
621
|
+
message: "Theme ID (optional, press Enter to skip)"
|
|
622
|
+
}, { onCancel: () => {
|
|
623
|
+
console.log("\nCancelled.");
|
|
624
|
+
process.exit(0);
|
|
625
|
+
} })).themeId;
|
|
626
|
+
if (!store) {
|
|
627
|
+
console.error("Error: Store name is required.");
|
|
628
|
+
process.exit(1);
|
|
629
|
+
}
|
|
630
|
+
envConfig = buildEnvConfig(config, {
|
|
631
|
+
store,
|
|
632
|
+
themeId
|
|
633
|
+
});
|
|
612
634
|
}
|
|
613
|
-
const envConfig = buildEnvConfig(config, {
|
|
614
|
-
store,
|
|
615
|
-
themeId
|
|
616
|
-
});
|
|
617
635
|
config.environments[envName] = envConfig;
|
|
618
636
|
saveConfig(configPath, config);
|
|
619
637
|
console.log(`\n${existsSync(configPath) ? "Updated" : "Created"} ${configPath} with '${envName}' environment`);
|
|
@@ -694,9 +712,12 @@ Details:
|
|
|
694
712
|
Creates or updates an unpublished theme for reviewing branch changes.
|
|
695
713
|
Theme is named "AG Preview: <branch>" for easy identification.
|
|
696
714
|
|
|
697
|
-
On first deploy: Clones the live theme as a starting point.
|
|
715
|
+
On first deploy: Clones the live theme (or --source theme) as a starting point.
|
|
698
716
|
On subsequent deploys: Updates the existing preview theme.
|
|
699
717
|
|
|
718
|
+
Use --theme to update a specific theme directly (skips theme lookup/creation).
|
|
719
|
+
Use --source to specify which theme to clone from instead of the live theme.
|
|
720
|
+
|
|
700
721
|
Writes deployment info to deploy.env:
|
|
701
722
|
- PREVIEW_URL: Theme preview URL
|
|
702
723
|
- EDITOR_URL: Theme editor URL
|
|
@@ -710,25 +731,41 @@ Environment:
|
|
|
710
731
|
|
|
711
732
|
Examples:
|
|
712
733
|
$ ag deploy:review --branch feature/new-header
|
|
713
|
-
$ ag deploy:review -b $CI_COMMIT_REF_NAME
|
|
734
|
+
$ ag deploy:review -b $CI_COMMIT_REF_NAME
|
|
735
|
+
$ ag deploy:review -b my-branch --theme 123456789
|
|
736
|
+
$ ag deploy:review -b my-branch --source 987654321`;
|
|
714
737
|
function register$5(program$1) {
|
|
715
|
-
program$1.command("deploy:review").description("Deploy a review app theme for the current branch").addHelpText("after", helpText$5).requiredOption("-b, --branch <branch>", "Git branch name").option("-p, --path <path>", "Theme directory path", "theme").action(deployReview);
|
|
738
|
+
program$1.command("deploy:review").description("Deploy a review app theme for the current branch").addHelpText("after", helpText$5).requiredOption("-b, --branch <branch>", "Git branch name").option("-p, --path <path>", "Theme directory path", "theme").option("-t, --theme <themeId>", "Target theme ID to update directly").option("-s, --source <themeId>", "Source theme ID to duplicate from").action(deployReview);
|
|
716
739
|
}
|
|
717
740
|
function deployReview(options) {
|
|
718
|
-
const { branch, path } = options;
|
|
741
|
+
const { branch, path, theme, source } = options;
|
|
719
742
|
const themeName = `AG Preview: ${branch}`;
|
|
720
743
|
console.log(`Setting up review app for branch: ${branch}`);
|
|
721
744
|
let reviewThemeId;
|
|
722
|
-
|
|
723
|
-
if (
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
console.log(`Cloning from published theme ID: ${liveTheme.id}`);
|
|
728
|
-
reviewThemeId = duplicateTheme(liveTheme.id, themeName).theme.id;
|
|
745
|
+
let existingTheme;
|
|
746
|
+
if (theme) {
|
|
747
|
+
reviewThemeId = Number.parseInt(theme, 10);
|
|
748
|
+
console.log(`Using provided theme ID: ${reviewThemeId}`);
|
|
749
|
+
existingTheme = { id: reviewThemeId };
|
|
729
750
|
} else {
|
|
730
|
-
|
|
731
|
-
|
|
751
|
+
existingTheme = findThemeByName(themeName);
|
|
752
|
+
if (!existingTheme) {
|
|
753
|
+
console.log("Creating new unpublished theme...");
|
|
754
|
+
let sourceThemeId;
|
|
755
|
+
if (source) {
|
|
756
|
+
sourceThemeId = Number.parseInt(source, 10);
|
|
757
|
+
console.log(`Using provided source theme ID: ${sourceThemeId}`);
|
|
758
|
+
} else {
|
|
759
|
+
const liveTheme = findLiveTheme();
|
|
760
|
+
if (!liveTheme) throw new Error("No live theme found to clone from");
|
|
761
|
+
sourceThemeId = liveTheme.id;
|
|
762
|
+
console.log(`Cloning from published theme ID: ${sourceThemeId}`);
|
|
763
|
+
}
|
|
764
|
+
reviewThemeId = duplicateTheme(sourceThemeId, themeName).theme.id;
|
|
765
|
+
} else {
|
|
766
|
+
console.log(`Theme already exists with ID: ${existingTheme.id}`);
|
|
767
|
+
reviewThemeId = existingTheme.id;
|
|
768
|
+
}
|
|
732
769
|
}
|
|
733
770
|
console.log(`Deploying branch ${branch} to theme ID: ${reviewThemeId}`);
|
|
734
771
|
const { preview_url, editor_url } = pushTheme(path, reviewThemeId, defaultIgnores).theme;
|