@acidgreen-au/ag-cicd-cli 0.0.6 → 0.0.7
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 +30 -17
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -532,20 +532,42 @@ function loadConfig(configPath) {
|
|
|
532
532
|
function saveConfig(configPath, config) {
|
|
533
533
|
writeFileSync(configPath, stringify(config));
|
|
534
534
|
}
|
|
535
|
+
function validateConfig(config, envName, options) {
|
|
536
|
+
if (config.environments[envName] && !options.force) return {
|
|
537
|
+
success: false,
|
|
538
|
+
message: `Environment '${envName}' already exists. Use --force to overwrite.`,
|
|
539
|
+
envName
|
|
540
|
+
};
|
|
541
|
+
if (envName !== "default" && !config.environments.default) return {
|
|
542
|
+
success: false,
|
|
543
|
+
message: "Default environment must be created first. Run 'ag config:shopify' without arguments.",
|
|
544
|
+
envName
|
|
545
|
+
};
|
|
546
|
+
return null;
|
|
547
|
+
}
|
|
548
|
+
function buildEnvConfig(config, response) {
|
|
549
|
+
const defaultEnv = config.environments.default;
|
|
550
|
+
const path = defaultEnv?.path ?? DEFAULT_PATH;
|
|
551
|
+
const ignore = defaultEnv?.ignore ?? DEFAULT_IGNORES;
|
|
552
|
+
const envConfig = {
|
|
553
|
+
store: response.store,
|
|
554
|
+
path,
|
|
555
|
+
ignore
|
|
556
|
+
};
|
|
557
|
+
if (response.themeId) envConfig.theme = response.themeId;
|
|
558
|
+
return envConfig;
|
|
559
|
+
}
|
|
535
560
|
async function configShopify(name, options) {
|
|
536
561
|
const configPath = "shopify.theme.toml";
|
|
537
562
|
const envName = name ?? "default";
|
|
538
563
|
const config = loadConfig(configPath);
|
|
539
564
|
if (!config.environments) config.environments = {};
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
}
|
|
544
|
-
if (envName !== "default" && !config.environments.default) {
|
|
545
|
-
console.error("Error: Default environment must be created first. Run 'ag config:shopify' without arguments.");
|
|
565
|
+
const validationError = validateConfig(config, envName, options);
|
|
566
|
+
if (validationError) {
|
|
567
|
+
console.error(`Error: ${validationError.message}`);
|
|
546
568
|
process.exit(1);
|
|
547
569
|
}
|
|
548
|
-
const
|
|
570
|
+
const envConfig = buildEnvConfig(config, await prompts([{
|
|
549
571
|
type: "text",
|
|
550
572
|
name: "store",
|
|
551
573
|
message: "Store name (e.g., my-store.myshopify.com)",
|
|
@@ -557,16 +579,7 @@ async function configShopify(name, options) {
|
|
|
557
579
|
}], { onCancel: () => {
|
|
558
580
|
console.log("\nCancelled.");
|
|
559
581
|
process.exit(0);
|
|
560
|
-
} });
|
|
561
|
-
const defaultEnv = config.environments.default;
|
|
562
|
-
const path = defaultEnv?.path ?? DEFAULT_PATH;
|
|
563
|
-
const ignore = defaultEnv?.ignore ?? DEFAULT_IGNORES;
|
|
564
|
-
const envConfig = {
|
|
565
|
-
store: response.store,
|
|
566
|
-
path,
|
|
567
|
-
ignore
|
|
568
|
-
};
|
|
569
|
-
if (response.themeId) envConfig.theme = response.themeId;
|
|
582
|
+
} }));
|
|
570
583
|
config.environments[envName] = envConfig;
|
|
571
584
|
saveConfig(configPath, config);
|
|
572
585
|
console.log(`\n${existsSync(configPath) ? "Updated" : "Created"} ${configPath} with '${envName}' environment`);
|