@webship.co/workspace-azure 1.0.12 → 1.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webship.co/workspace-azure",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Azure App Service for Webship Workspace: the AZURE menu on every site row, the web app and its deployment slots with their URLs, zip deploy, log tail, deployment history. It carries its AI items, each placed in the workspace folder of its kind: an agent, a skill, a command and a prompt. A provider of @webship.co/workspace-hosting.",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  # azure_do_push <project_path> <id> <env> deploy
12
12
  # azure_do_logs <project_path> <id> <env>
13
13
  # azure_do_activities <project_path> <id>
14
- # azure_status <project_path> <id> the closing status block
14
+ # azure_status <project_path> <id> the closing status block; fails when the provider cannot be reached
15
15
 
16
16
  AZURE_LINK_FILE=".azure/workspace.yml";
17
17
 
@@ -152,7 +152,9 @@ function azure_project_tool() {
152
152
  azure_do_activities "${project_path}" "${linked_id}" || true ;
153
153
  fi
154
154
 
155
- # Default (and after any verb): status.
155
+ # Default (and after any verb): status. The local part always shows; when the provider cannot be
156
+ # reached (no CLI, no login, no token), azure_status says what is missing and the run fails.
157
+ local status_rc=0;
156
158
  echo "";
157
159
  echo "*---------------------------------------------------------------------*";
158
160
  echo " ${doc_name}/${PROJECT_NAME} on Azure";
@@ -165,9 +167,10 @@ function azure_project_tool() {
165
167
  local selected;
166
168
  selected="$(azure_selected_env "${project_path}")";
167
169
  echo " env: ${selected:-none selected — --environments then --select <name>}";
168
- azure_status "${project_path}" "${linked_id}" ;
170
+ azure_status "${project_path}" "${linked_id}" || status_rc=1 ;
169
171
  fi
170
172
  echo "*---------------------------------------------------------------------*";
171
173
 
172
174
  cd "${WORKSPACE_ROOT}/${doc_name}";
175
+ return ${status_rc} ;
173
176
  }
@@ -42,10 +42,13 @@ function azure_list_environments() {
42
42
  }
43
43
 
44
44
  function azure_do_environments() {
45
- local project_path="$1";
45
+ local project_path="$1" row;
46
+ # Read first, then print: piped straight into awk, a failed az left awk's own success as the answer
47
+ # and an empty list on the screen.
46
48
  # shellcheck disable=SC2046
47
- az webapp show -g "$(azure_rg "${project_path}")" -n "$(azure_app "${project_path}")" $(azure_sub) -o tsv --query '[name, state, defaultHostName]' 2>/dev/null \
48
- | awk '{ printf " %-24s %-10s https://%s\n", "production", tolower($2), $3 }' || { echo " (could not read the web app — check az account show)"; return 1; } ;
49
+ row="$(az webapp show -g "$(azure_rg "${project_path}")" -n "$(azure_app "${project_path}")" $(azure_sub) -o tsv --query '[name, state, defaultHostName]' 2>/dev/null)" && [ -n "${row}" ] \
50
+ || { echo " (could not read the web app — check az account show)"; return 1; } ;
51
+ printf '%s\n' "${row}" | awk '{ printf " %-24s %-10s https://%s\n", "production", tolower($2), $3 }' ;
49
52
  # shellcheck disable=SC2046
50
53
  az webapp deployment slot list -g "$(azure_rg "${project_path}")" -n "$(azure_app "${project_path}")" $(azure_sub) -o tsv --query '[].[name, state, defaultHostName]' 2>/dev/null \
51
54
  | awk '{ printf " %-24s %-10s https://%s\n", $1, tolower($2), $3 }' ;
@@ -80,19 +83,27 @@ function azure_do_activities() {
80
83
  # shellcheck disable=SC2046
81
84
  az webapp log deployment list -g "$(azure_rg "${project_path}")" -n "$(azure_app "${project_path}")" $(azure_sub) -o json 2>/dev/null | python3 -c 'import json,sys
82
85
  for d in json.load(sys.stdin)[:10]:
83
- print(" %-20s %-10s %s" % ((d.get("received_time") or d.get("start_time") or "")[:19], "ok" if d.get("complete") else "running", (d.get("message") or d.get("id") or "")[:60]))' \
86
+ print(" %-20s %-10s %s" % ((d.get("received_time") or d.get("start_time") or "")[:19], "ok" if d.get("complete") else "running", (d.get("message") or d.get("id") or "")[:60]))' 2>/dev/null \
84
87
  || echo " (could not list the deployments)" ;
85
88
  }
86
89
 
87
90
  function azure_status() {
88
- local project_path="$1" id="$2";
91
+ local project_path="$1" id="$2" missing rc=0;
89
92
  if [ -z "${id}" ] ; then
90
93
  echo " (the link is resource-group/web-app-name; az webapp list)";
91
94
  return 0 ;
92
95
  fi
93
96
  echo "";
94
- azure_do_environments "${project_path}" ;
97
+ # Without az or its login nothing below can answer: say once what is missing, in ensure_azure's
98
+ # words, and fail. The link and the console are known here and still show.
99
+ if missing="$(ensure_azure)" ; then
100
+ azure_do_environments "${project_path}" || rc=1 ;
101
+ else
102
+ [ -n "${missing}" ] && sed 's/^/ /' <<< "${missing}" ;
103
+ rc=1 ;
104
+ fi
95
105
  echo "";
96
106
  echo " Console: https://portal.azure.com/ → App Services → $(azure_app "${project_path}")";
97
107
  echo " --push zip-deploys the committed tree to the selected slot; --logs tails it.";
108
+ return ${rc} ;
98
109
  }