@acidgreen-au/ag-cicd-cli 0.6.1 → 0.7.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 +53 -39
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -845,10 +845,10 @@ function deploy(options) {
|
|
|
845
845
|
}
|
|
846
846
|
|
|
847
847
|
//#endregion
|
|
848
|
-
//#region src/commands/deploy-
|
|
848
|
+
//#region src/commands/deploy-preview.ts
|
|
849
849
|
const helpText$5 = `
|
|
850
850
|
Details:
|
|
851
|
-
Creates or updates an unpublished theme for
|
|
851
|
+
Creates or updates an unpublished theme for previewing branch changes.
|
|
852
852
|
Theme is named "AG Preview: <branch>" for easy identification.
|
|
853
853
|
|
|
854
854
|
On first deploy: Clones the live theme (or --source theme) as a starting point.
|
|
@@ -869,23 +869,23 @@ Environment:
|
|
|
869
869
|
CI_COMMIT_REF_NAME Git branch name (GitLab CI)
|
|
870
870
|
|
|
871
871
|
Examples:
|
|
872
|
-
$ ag deploy:
|
|
873
|
-
$ ag deploy:
|
|
874
|
-
$ ag deploy:
|
|
875
|
-
$ ag deploy:
|
|
872
|
+
$ ag deploy:preview --branch feature/new-header
|
|
873
|
+
$ ag deploy:preview -b $CI_COMMIT_REF_NAME
|
|
874
|
+
$ ag deploy:preview -b my-branch --theme 123456789
|
|
875
|
+
$ ag deploy:preview -b my-branch --source 987654321`;
|
|
876
876
|
function register$5(program$1) {
|
|
877
|
-
program$1.command("deploy:
|
|
877
|
+
program$1.command("deploy:preview").description("Deploy a preview 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(deployPreview);
|
|
878
878
|
}
|
|
879
|
-
function
|
|
879
|
+
function deployPreview(options) {
|
|
880
880
|
const { branch, path, theme, source } = options;
|
|
881
881
|
const themeName = previewBranchName(branch);
|
|
882
|
-
console.log(`Setting up
|
|
883
|
-
let
|
|
882
|
+
console.log(`Setting up preview for branch: ${branch}`);
|
|
883
|
+
let previewThemeId;
|
|
884
884
|
let existingTheme;
|
|
885
885
|
if (theme) {
|
|
886
|
-
|
|
887
|
-
console.log(`Using provided theme ID: ${
|
|
888
|
-
existingTheme = { id:
|
|
886
|
+
previewThemeId = Number.parseInt(theme, 10);
|
|
887
|
+
console.log(`Using provided theme ID: ${previewThemeId}`);
|
|
888
|
+
existingTheme = { id: previewThemeId };
|
|
889
889
|
} else {
|
|
890
890
|
existingTheme = findThemeByName(themeName);
|
|
891
891
|
if (!existingTheme) {
|
|
@@ -900,18 +900,18 @@ function deployReview(options) {
|
|
|
900
900
|
sourceThemeId = liveTheme.id;
|
|
901
901
|
console.log(`Cloning from published theme ID: ${sourceThemeId}`);
|
|
902
902
|
}
|
|
903
|
-
|
|
903
|
+
previewThemeId = duplicateTheme(sourceThemeId, themeName).theme.id;
|
|
904
904
|
} else {
|
|
905
905
|
console.log(`Theme already exists with ID: ${existingTheme.id}`);
|
|
906
|
-
|
|
906
|
+
previewThemeId = existingTheme.id;
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
|
-
console.log(`Deploying branch ${branch} to theme ID: ${
|
|
910
|
-
const { preview_url, editor_url } = pushTheme(path,
|
|
911
|
-
console.log("
|
|
909
|
+
console.log(`Deploying branch ${branch} to theme ID: ${previewThemeId}`);
|
|
910
|
+
const { preview_url, editor_url } = pushTheme(path, previewThemeId, DEFAULT_IGNORES).theme;
|
|
911
|
+
console.log("Preview deployed successfully!");
|
|
912
912
|
console.log(`Preview URL: ${preview_url}`);
|
|
913
913
|
console.log(`Editor URL: ${editor_url}`);
|
|
914
|
-
writeDeployEnv(preview_url, editor_url,
|
|
914
|
+
writeDeployEnv(preview_url, editor_url, previewThemeId, { EXISTING_THEME_ID: existingTheme?.id?.toString() ?? "" });
|
|
915
915
|
}
|
|
916
916
|
|
|
917
917
|
//#endregion
|
|
@@ -960,10 +960,13 @@ async function dev(_options, command) {
|
|
|
960
960
|
const helpText$3 = `
|
|
961
961
|
Details:
|
|
962
962
|
Creates a new theme for production releases. Clones the current live theme
|
|
963
|
-
to preserve any theme editor customizations, then pushes
|
|
963
|
+
(or --source theme) to preserve any theme editor customizations, then pushes
|
|
964
|
+
your code changes.
|
|
964
965
|
|
|
965
966
|
Theme is named "AG Release: <name>" for easy identification.
|
|
966
967
|
|
|
968
|
+
Use --source to specify which theme to clone from instead of the live theme.
|
|
969
|
+
|
|
967
970
|
Writes deployment info to deploy.env:
|
|
968
971
|
- PREVIEW_URL: Release theme preview URL
|
|
969
972
|
- EDITOR_URL: Release theme editor URL
|
|
@@ -977,26 +980,37 @@ Environment:
|
|
|
977
980
|
|
|
978
981
|
Examples:
|
|
979
982
|
$ ag release --name v1.2.3
|
|
980
|
-
$ ag release -n $CI_COMMIT_TAG
|
|
983
|
+
$ ag release -n $CI_COMMIT_TAG
|
|
984
|
+
$ ag release -n v1.2.3 --source 123456789`;
|
|
981
985
|
function register$3(program$1) {
|
|
982
|
-
program$1.command("release").description("Create a release theme by cloning live and pushing changes").addHelpText("after", helpText$3).requiredOption("-n, --name <name>", "Release name (usually git tag)").option("-p, --path <path>", "Theme directory path", "theme").action(release);
|
|
986
|
+
program$1.command("release").description("Create a release theme by cloning live and pushing changes").addHelpText("after", helpText$3).requiredOption("-n, --name <name>", "Release name (usually git tag)").option("-p, --path <path>", "Theme directory path", "theme").option("-s, --source <themeId>", "Source theme ID to clone from").action(release);
|
|
983
987
|
}
|
|
984
988
|
function release(options) {
|
|
985
|
-
const { name, path } = options;
|
|
989
|
+
const { name, path, source } = options;
|
|
986
990
|
const themeName = `AG Release: ${name}`;
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
+
let sourceThemeId;
|
|
992
|
+
let liveThemeId;
|
|
993
|
+
if (source) {
|
|
994
|
+
sourceThemeId = Number.parseInt(source, 10);
|
|
995
|
+
console.log(`Using provided source theme ID: ${sourceThemeId}`);
|
|
996
|
+
liveThemeId = findLiveTheme()?.id;
|
|
997
|
+
} else {
|
|
998
|
+
const liveTheme = findLiveTheme();
|
|
999
|
+
if (!liveTheme) throw new Error("No live theme found to clone from");
|
|
1000
|
+
sourceThemeId = liveTheme.id;
|
|
1001
|
+
liveThemeId = liveTheme.id;
|
|
1002
|
+
console.log(`Cloning from published theme ID: ${sourceThemeId}`);
|
|
1003
|
+
}
|
|
1004
|
+
const releaseThemeId = duplicateTheme(sourceThemeId, themeName).theme.id;
|
|
991
1005
|
const { preview_url, editor_url } = pushTheme(path, releaseThemeId, DEFAULT_IGNORES).theme;
|
|
992
1006
|
console.log("Release deployed successfully!");
|
|
993
1007
|
console.log(`Preview URL: ${preview_url}`);
|
|
994
1008
|
console.log(`Editor URL: ${editor_url}`);
|
|
995
|
-
writeDeployEnv(preview_url, editor_url, releaseThemeId, { PUBLISHED_THEME_ID:
|
|
1009
|
+
writeDeployEnv(preview_url, editor_url, releaseThemeId, { PUBLISHED_THEME_ID: liveThemeId?.toString() ?? "" });
|
|
996
1010
|
}
|
|
997
1011
|
|
|
998
1012
|
//#endregion
|
|
999
|
-
//#region src/commands/stop-
|
|
1013
|
+
//#region src/commands/stop-preview.ts
|
|
1000
1014
|
const helpText$2 = `
|
|
1001
1015
|
Details:
|
|
1002
1016
|
Finds and deletes the unpublished theme named "AG Preview: <branch>".
|
|
@@ -1010,20 +1024,20 @@ Environment:
|
|
|
1010
1024
|
CI_COMMIT_REF_NAME Git branch name (GitLab CI)
|
|
1011
1025
|
|
|
1012
1026
|
Examples:
|
|
1013
|
-
$ ag stop:
|
|
1014
|
-
$ ag stop:
|
|
1027
|
+
$ ag stop:preview --branch feature/new-header
|
|
1028
|
+
$ ag stop:preview -b $CI_COMMIT_REF_NAME`;
|
|
1015
1029
|
function register$2(program$1) {
|
|
1016
|
-
program$1.command("stop:
|
|
1030
|
+
program$1.command("stop:preview").description("Delete the preview theme for a branch").addHelpText("after", helpText$2).requiredOption("-b, --branch <branch>", "Git branch name").action(stopPreview);
|
|
1017
1031
|
}
|
|
1018
|
-
function
|
|
1032
|
+
function stopPreview(options) {
|
|
1019
1033
|
const { branch } = options;
|
|
1020
1034
|
const themeName = previewBranchName(branch);
|
|
1021
|
-
console.log(`Cleaning up
|
|
1035
|
+
console.log(`Cleaning up preview for branch: ${branch}`);
|
|
1022
1036
|
const theme = findThemeByName(themeName);
|
|
1023
1037
|
if (theme) {
|
|
1024
1038
|
console.log(`Deleting theme: ${themeName} (ID: ${theme.id})`);
|
|
1025
1039
|
deleteTheme(theme.id);
|
|
1026
|
-
console.log("
|
|
1040
|
+
console.log("Preview cleaned up successfully!");
|
|
1027
1041
|
} else console.log(`No theme found with name: ${themeName}`);
|
|
1028
1042
|
}
|
|
1029
1043
|
|
|
@@ -1033,7 +1047,7 @@ const helpText$1 = `
|
|
|
1033
1047
|
Contexts:
|
|
1034
1048
|
all Check all variables for all contexts (default)
|
|
1035
1049
|
deploy Check variables for theme deployment
|
|
1036
|
-
|
|
1050
|
+
preview Check variables for preview deployment
|
|
1037
1051
|
release Check variables for release deployment
|
|
1038
1052
|
codequality Check variables for code quality checks
|
|
1039
1053
|
|
|
@@ -1048,7 +1062,7 @@ Examples:
|
|
|
1048
1062
|
$ ag validate-env --context deploy
|
|
1049
1063
|
$ ag validate-env --vars SHOPIFY_FLAG_STORE CUSTOM_VAR`;
|
|
1050
1064
|
function register$1(program$1) {
|
|
1051
|
-
program$1.command("validate-env").description("Validate required environment variables are set").addHelpText("after", helpText$1).option("-c, --context <context>", "Validation context (deploy,
|
|
1065
|
+
program$1.command("validate-env").description("Validate required environment variables are set").addHelpText("after", helpText$1).option("-c, --context <context>", "Validation context (deploy, preview, release, codequality, all)").option("-v, --vars <vars...>", "Specific variables to check").action(validateEnv);
|
|
1052
1066
|
}
|
|
1053
1067
|
const commonVars = [{
|
|
1054
1068
|
name: "SHOPIFY_CLI_THEME_TOKEN",
|
|
@@ -1065,10 +1079,10 @@ const contextVars = {
|
|
|
1065
1079
|
required: true,
|
|
1066
1080
|
description: "Target theme ID for deployment"
|
|
1067
1081
|
}],
|
|
1068
|
-
|
|
1082
|
+
preview: [{
|
|
1069
1083
|
name: "CI_COMMIT_REF_NAME",
|
|
1070
1084
|
required: true,
|
|
1071
|
-
description: "Git branch name for
|
|
1085
|
+
description: "Git branch name for preview"
|
|
1072
1086
|
}],
|
|
1073
1087
|
release: [{
|
|
1074
1088
|
name: "CI_COMMIT_TAG",
|