@acidgreen-au/ag-cicd-cli 0.0.7 → 0.1.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +48 -14
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -506,14 +506,15 @@ 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
- Prompts for:
509
+ Prompts for (unless provided via options):
510
510
  - Store name (required): Your myshopify.com store URL
511
511
  - Theme ID (optional): Target theme ID for deployment
512
512
 
513
513
  Examples:
514
- $ ag config:shopify # Create/update default environment
515
- $ ag config:shopify production # Add production environment
516
- $ ag config:shopify staging --force # Overwrite staging environment`;
514
+ $ ag config:shopify # Create/update default environment
515
+ $ ag config:shopify production # Add production environment
516
+ $ ag config:shopify staging --force # Overwrite staging environment
517
+ $ ag config:shopify --store my-store.myshopify.com --theme 123456789`;
517
518
  const DEFAULT_IGNORES = [
518
519
  "templates/*.json",
519
520
  "locales/*.json",
@@ -523,7 +524,7 @@ const DEFAULT_IGNORES = [
523
524
  ];
524
525
  const DEFAULT_PATH = "theme";
525
526
  function register$7(program$1) {
526
- 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").action(configShopify);
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);
527
528
  }
528
529
  function loadConfig(configPath) {
529
530
  if (!existsSync(configPath)) return { environments: {} };
@@ -536,12 +537,14 @@ function validateConfig(config, envName, options) {
536
537
  if (config.environments[envName] && !options.force) return {
537
538
  success: false,
538
539
  message: `Environment '${envName}' already exists. Use --force to overwrite.`,
539
- envName
540
+ envName,
541
+ errorCode: "ENV_EXISTS"
540
542
  };
541
543
  if (envName !== "default" && !config.environments.default) return {
542
544
  success: false,
543
- message: "Default environment must be created first. Run 'ag config:shopify' without arguments.",
544
- envName
545
+ message: "Default environment does not exist.",
546
+ envName,
547
+ errorCode: "DEFAULT_MISSING"
545
548
  };
546
549
  return null;
547
550
  }
@@ -559,27 +562,58 @@ function buildEnvConfig(config, response) {
559
562
  }
560
563
  async function configShopify(name, options) {
561
564
  const configPath = "shopify.theme.toml";
562
- const envName = name ?? "default";
565
+ let envName = name ?? "default";
563
566
  const config = loadConfig(configPath);
564
567
  if (!config.environments) config.environments = {};
565
568
  const validationError = validateConfig(config, envName, options);
566
- if (validationError) {
569
+ if (validationError) if (validationError.errorCode === "DEFAULT_MISSING") {
570
+ const { createDefault } = await prompts({
571
+ type: "confirm",
572
+ name: "createDefault",
573
+ message: `Default environment does not exist. Create 'default' instead of '${envName}'?`,
574
+ initial: true
575
+ }, { onCancel: () => {
576
+ console.log("\nCancelled.");
577
+ process.exit(0);
578
+ } });
579
+ if (createDefault) envName = "default";
580
+ else {
581
+ console.log("\nCancelled.");
582
+ process.exit(0);
583
+ }
584
+ } else {
567
585
  console.error(`Error: ${validationError.message}`);
568
586
  process.exit(1);
569
587
  }
570
- const envConfig = buildEnvConfig(config, await prompts([{
588
+ const defaultEnv = config.environments.default;
589
+ let store = options.store;
590
+ let themeId = options.theme;
591
+ if (!store) store = (await prompts({
571
592
  type: "text",
572
593
  name: "store",
573
594
  message: "Store name (e.g., my-store.myshopify.com)",
595
+ initial: defaultEnv?.store,
574
596
  validate: (value) => value.length > 0 || "Store name is required"
575
- }, {
597
+ }, { onCancel: () => {
598
+ console.log("\nCancelled.");
599
+ process.exit(0);
600
+ } })).store;
601
+ if (themeId === void 0) themeId = (await prompts({
576
602
  type: "text",
577
603
  name: "themeId",
578
604
  message: "Theme ID (optional, press Enter to skip)"
579
- }], { onCancel: () => {
605
+ }, { onCancel: () => {
580
606
  console.log("\nCancelled.");
581
607
  process.exit(0);
582
- } }));
608
+ } })).themeId;
609
+ if (!store) {
610
+ console.error("Error: Store name is required.");
611
+ process.exit(1);
612
+ }
613
+ const envConfig = buildEnvConfig(config, {
614
+ store,
615
+ themeId
616
+ });
583
617
  config.environments[envName] = envConfig;
584
618
  saveConfig(configPath, config);
585
619
  console.log(`\n${existsSync(configPath) ? "Updated" : "Created"} ${configPath} with '${envName}' environment`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acidgreen-au/ag-cicd-cli",
3
- "version": "0.0.7",
3
+ "version": "0.1.0",
4
4
  "description": "Acidgreen CI/CD CLI tools",
5
5
  "type": "module",
6
6
  "bin": {