@numericoach/gskills-admin-cli 0.1.24 → 0.1.26

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/README.md CHANGED
@@ -50,6 +50,17 @@ gskills-admin topics help --output json
50
50
 
51
51
  Use the listed `cache.scopes` with `gskills-admin cache invalidate` after create, update, or soft-delete when the end-user view must reflect the change immediately.
52
52
 
53
+ Large local videos can be uploaded directly to GSkills storage before creating or updating internal knowledge and resources. The CLI asks the app for a signed upload URL, streams the local file directly to GCS, then writes the normal row with the returned URL. Use `--instance` for client-specific content.
54
+
55
+ ```bash
56
+ gskills-admin internal-knowledge create --instance dev-numericoach --upload-file ./capsule.mp4 --data '{"title":"Capsule test","language":"fr","isActive":true,"isAIAllowed":false}' --dry-run --output json
57
+ gskills-admin internal-knowledge create --instance dev-numericoach --upload-file ./capsule.mp4 --data '{"title":"Capsule test","language":"fr","isActive":true,"isAIAllowed":false}' --output json
58
+ gskills-admin resources create --instance dev-numericoach --upload-file ./webinar.mp4 --data '{"title":"Webinar test","type":"WEBINAR","language":"fr","isActive":true}' --dry-run --output json
59
+ gskills-admin resources update <resourceId> --upload-file ./webinar-v2.mp4 --data '{}' --output json
60
+ ```
61
+
62
+ Use `--mime-type` when the extension is ambiguous, and `--upload-name` when the stored file name needs a cleaner label.
63
+
53
64
  AI translation is available for content that has native AI translation in the editor:
54
65
 
55
66
  Warning: `translate pages` rewrites each translated page from the source page. It is not a diff update. Recreating translated pages this way can lose activity-specific fields, quiz ids, embedded ids, or future custom block data if the translator does not preserve them. Prefer the app diff update flow for pages with activities or custom blocks.
@@ -154,6 +165,7 @@ gskills-admin skills install --name gskills-customer-playbooks --target ~/.codex
154
165
  gskills-admin skills install --name gskills-feedback-db-ops --target ~/.codex/skills
155
166
  gskills-admin skills install --name gskills-source-id-repair --target ~/.codex/skills
156
167
  gskills-admin skills install --name gskills-user-session-invalidation --target ~/.codex/skills
168
+ gskills-admin skills install --name gskills-admin-cli-publishing --target ~/.codex/skills
157
169
  ```
158
170
 
159
171
  ## Output
@@ -186,6 +186,9 @@ var loginWithGSkills = async (input) => {
186
186
  if (callback.state !== state) {
187
187
  throw new CliError("GSkills auth state mismatch", 403);
188
188
  }
189
+ if (!callback.code) {
190
+ throw new CliError("GSkills CLI login callback did not include an auth code", 403);
191
+ }
189
192
  const tokenResponse = await fetch(new URL("/api/cli/auth/token", baseUrl), {
190
193
  method: "POST",
191
194
  headers: {
@@ -214,6 +217,36 @@ var loginWithGSkills = async (input) => {
214
217
  user: payload.user
215
218
  };
216
219
  };
220
+ var waitForGoogleSheetsOAuth = async (input) => {
221
+ const baseUrl = normalizeBaseUrl(input.baseUrl);
222
+ const host = input.host ?? "127.0.0.1";
223
+ const state = randomUUID();
224
+ const callback = await waitForLocalCallback(host, input.port ?? 0, async (redirectUri) => {
225
+ const startUrl = new URL("/api/cli/imported-sheets/oauth/start", baseUrl);
226
+ startUrl.searchParams.set("redirect_uri", redirectUri);
227
+ startUrl.searchParams.set("state", state);
228
+ startUrl.searchParams.set("instanceId", input.instanceId);
229
+ startUrl.searchParams.set("lang", input.lang ?? "fr");
230
+ if (input.ownerEmail)
231
+ startUrl.searchParams.set("ownerEmail", input.ownerEmail);
232
+ const opened = await openUrl(startUrl.toString());
233
+ if (opened) {
234
+ process.stderr.write(`Opened ${startUrl.toString()}
235
+ `);
236
+ }
237
+ }, {
238
+ timeoutMs: input.timeoutMs,
239
+ successMessage: "Google Sheets access connected. You can go back to Codex now.",
240
+ errorPrefix: "Google Sheets OAuth failed"
241
+ });
242
+ if (callback.state !== state) {
243
+ throw new CliError("Google Sheets OAuth state mismatch", 403);
244
+ }
245
+ return {
246
+ connected: true,
247
+ userEmail: callback.userEmail
248
+ };
249
+ };
217
250
  var getApiSession = async () => {
218
251
  const session = await readSession();
219
252
  if (!session) {
@@ -235,32 +268,42 @@ var whoami = async () => {
235
268
  }
236
269
  return payload;
237
270
  };
238
- var waitForLocalCallback = async (host, port, onReady) => {
271
+ var waitForLocalCallback = async (host, port, onReady, options = {}) => {
239
272
  return new Promise((resolve, reject) => {
273
+ const timeout = options.timeoutMs ? setTimeout(() => {
274
+ server.close();
275
+ reject(new CliError("Timed out waiting for browser OAuth callback", 408));
276
+ }, options.timeoutMs) : null;
277
+ const finish = (callback) => {
278
+ if (timeout)
279
+ clearTimeout(timeout);
280
+ server.close();
281
+ callback();
282
+ };
240
283
  const server = createServer((request, response) => {
241
284
  try {
242
285
  const url = new URL(request.url ?? "/", `http://${host}`);
243
286
  const code = url.searchParams.get("code");
244
287
  const state = url.searchParams.get("state");
288
+ const status = url.searchParams.get("status");
289
+ const userEmail = url.searchParams.get("userEmail") ?? undefined;
245
290
  const error = url.searchParams.get("error");
246
291
  if (error) {
247
- response.writeHead(403, { "content-type": "text/plain" });
248
- response.end(`GSkills CLI login failed: ${error}`);
249
- server.close();
250
- reject(new CliError(`GSkills CLI login failed: ${error}`, 403));
292
+ response.writeHead(403, { "content-type": "text/html; charset=utf-8" });
293
+ response.end(callbackHtml("Google Sheets access failed", `Error: ${escapeHtml(error)}`));
294
+ finish(() => reject(new CliError(`${options.errorPrefix ?? "GSkills CLI login failed"}: ${error}`, 403)));
251
295
  return;
252
296
  }
253
- if (!code || !state) {
297
+ if (!state) {
254
298
  response.writeHead(400, { "content-type": "text/plain" });
255
- response.end("Missing GSkills CLI auth code.");
299
+ response.end("Missing callback state.");
256
300
  return;
257
301
  }
258
- response.writeHead(200, { "content-type": "text/plain" });
259
- response.end("GSkills CLI login complete. You can close this tab.");
260
- server.close();
261
- resolve({ code, state });
302
+ response.writeHead(200, { "content-type": "text/html; charset=utf-8" });
303
+ response.end(callbackHtml("All good", options.successMessage ?? "GSkills CLI login complete. You can close this tab."));
304
+ finish(() => resolve({ code: code ?? undefined, state, status: status ?? undefined, userEmail }));
262
305
  } catch (error) {
263
- reject(error);
306
+ finish(() => reject(error));
264
307
  }
265
308
  });
266
309
  server.on("error", reject);
@@ -279,6 +322,29 @@ var waitForLocalCallback = async (host, port, onReady) => {
279
322
  });
280
323
  });
281
324
  };
325
+ var callbackHtml = (title, message) => `<!doctype html>
326
+ <html lang="en">
327
+ <head>
328
+ <meta charset="utf-8" />
329
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
330
+ <title>${escapeHtml(title)}</title>
331
+ <style>
332
+ body { margin: 0; min-height: 100vh; display: grid; place-items: center; font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #f8fafc; color: #0f172a; }
333
+ main { width: min(520px, calc(100vw - 32px)); }
334
+ img { width: 40px; height: 40px; display: block; margin-bottom: 20px; }
335
+ h1 { margin: 0 0 10px; font-size: 24px; line-height: 1.2; }
336
+ p { margin: 0; color: #475569; font-size: 15px; line-height: 1.6; }
337
+ </style>
338
+ </head>
339
+ <body>
340
+ <main>
341
+ <img src="https://storage.googleapis.com/public-gskills/applications-icons/google-sheets-icon-2026.png" alt="" />
342
+ <h1>${escapeHtml(title)}</h1>
343
+ <p>${escapeHtml(message)}</p>
344
+ </main>
345
+ </body>
346
+ </html>`;
347
+ var escapeHtml = (value) => value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
282
348
  var normalizeBaseUrl = (value) => {
283
349
  const url = new URL(value);
284
350
  url.pathname = "";
@@ -324,7 +390,7 @@ var requestApi = async (path, init = {}) => {
324
390
  });
325
391
  const payload = await response.json().catch(() => null);
326
392
  if (!response.ok) {
327
- throw new CliError(payload?.error ?? `GSkills API request failed with ${response.status}`, response.status);
393
+ throw new CliError(payload?.error ?? `GSkills API request failed with ${response.status}`, response.status, payload?.details ?? undefined);
328
394
  }
329
395
  return payload;
330
396
  };
@@ -808,8 +874,10 @@ var resourceHelpRows = () => resources.map((resource) => ({
808
874
  aliases: resource.aliases.join(", ")
809
875
  }));
810
876
  // ../../src/cli/commands.ts
877
+ import { createReadStream } from "node:fs";
811
878
  import { cp, mkdir as mkdir2, readFile as readFile2, readdir, stat } from "node:fs/promises";
812
- import { dirname as dirname2, join as join2 } from "node:path";
879
+ import { basename, dirname as dirname2, extname, join as join2, resolve } from "node:path";
880
+ import { homedir as homedir2 } from "node:os";
813
881
  import { fileURLToPath } from "node:url";
814
882
  var runCommand = async (ctx) => {
815
883
  const [group, actionOrResource, maybeAction, ...rest] = ctx.args;
@@ -821,7 +889,7 @@ var runCommand = async (ctx) => {
821
889
  return runSkillsCommand(actionOrResource, ctx);
822
890
  if (group === "auth")
823
891
  return runAuthCommand(actionOrResource, ctx);
824
- if (group === "resources")
892
+ if (group === "resources" && !actionOrResource)
825
893
  return resourceHelpRows();
826
894
  if (group === "sync")
827
895
  return runSyncCommand(actionOrResource, ctx);
@@ -949,6 +1017,7 @@ var createResource = async (resource, ctx) => {
949
1017
  const instanceField = resource.instanceField === undefined ? "instanceId" : resource.instanceField;
950
1018
  if (instanceId && instanceField && !instanceField.includes(".") && data[instanceField] === undefined)
951
1019
  data[instanceField] = instanceId;
1020
+ await applyUploadFileData(resource, data, ctx, { id: null, instanceId: getInstanceIdFromData(data) ?? instanceId });
952
1021
  if (Object.keys(data).length === 0)
953
1022
  throw new CliError("Missing --data JSON", 2);
954
1023
  if (hasFlag(ctx, "dry-run"))
@@ -960,6 +1029,7 @@ var createResource = async (resource, ctx) => {
960
1029
  };
961
1030
  var updateResource = async (resource, id, ctx) => {
962
1031
  const data = parseJsonObject(getStringFlag(ctx, "data"), "--data");
1032
+ await applyUploadFileData(resource, data, ctx, { id, instanceId: getStringFlag(ctx, "instance") ?? getInstanceIdFromData(data) });
963
1033
  if (Object.keys(data).length === 0)
964
1034
  throw new CliError("Missing --data JSON", 2);
965
1035
  if (hasFlag(ctx, "dry-run"))
@@ -969,6 +1039,161 @@ var updateResource = async (resource, id, ctx) => {
969
1039
  body: JSON.stringify({ data })
970
1040
  });
971
1041
  };
1042
+ var UPLOADABLE_RESOURCE_NAMES = new Set(["internal-knowledge", "resources"]);
1043
+ var applyUploadFileData = async (resource, data, ctx, target) => {
1044
+ const uploadFilePath = getStringFlag(ctx, "upload-file");
1045
+ if (!uploadFilePath)
1046
+ return;
1047
+ if (!UPLOADABLE_RESOURCE_NAMES.has(resource.name)) {
1048
+ throw new CliError(`--upload-file is not supported for ${resource.name}`, 2);
1049
+ }
1050
+ const upload = await prepareDirectUpload(resource, uploadFilePath, ctx, target);
1051
+ if (hasFlag(ctx, "dry-run")) {
1052
+ data.__upload = upload;
1053
+ applyUploadedMediaData(resource, data, upload);
1054
+ return;
1055
+ }
1056
+ if (!isPreparedSignedUpload(upload)) {
1057
+ throw new CliError("Signed upload response was invalid", 1);
1058
+ }
1059
+ if (!target.id) {
1060
+ setUploadInstanceData(resource, data, upload.instanceId);
1061
+ }
1062
+ await uploadToSignedUrl(upload.signedUrl, upload.filePath, upload.contentType, upload.size);
1063
+ applyUploadedMediaData(resource, data, upload);
1064
+ };
1065
+ var prepareDirectUpload = async (resource, uploadFilePath, ctx, target) => {
1066
+ const filePath = resolveLocalPath(uploadFilePath);
1067
+ const fileStat = await stat(filePath).catch(() => null);
1068
+ if (!fileStat?.isFile()) {
1069
+ throw new CliError(`Upload file not found: ${uploadFilePath}`, 2);
1070
+ }
1071
+ const contentType = getStringFlag(ctx, "mime-type") ?? inferMimeType(filePath);
1072
+ const instanceId = await resolveUploadInstanceId(resource, target);
1073
+ const fileName = getStringFlag(ctx, "upload-name") ?? basename(filePath);
1074
+ if (hasFlag(ctx, "dry-run")) {
1075
+ return {
1076
+ filePath,
1077
+ fileName,
1078
+ contentType,
1079
+ size: fileStat.size,
1080
+ instanceId,
1081
+ directUpload: true
1082
+ };
1083
+ }
1084
+ const result = await requestApi("/api/cli/uploads/signed-url", {
1085
+ method: "POST",
1086
+ body: JSON.stringify({
1087
+ resource: resource.name,
1088
+ instanceId,
1089
+ fileName,
1090
+ contentType
1091
+ })
1092
+ });
1093
+ if (!isSignedUploadResult(result)) {
1094
+ throw new CliError("Signed upload response was invalid", 1);
1095
+ }
1096
+ return {
1097
+ ...result,
1098
+ filePath,
1099
+ contentType,
1100
+ size: fileStat.size,
1101
+ instanceId: result.instanceId
1102
+ };
1103
+ };
1104
+ var resolveUploadInstanceId = async (resource, target) => {
1105
+ if (target.instanceId)
1106
+ return target.instanceId;
1107
+ if (target.id) {
1108
+ const row = await requestApi(`/api/cli/${resource.name}/${target.id}`);
1109
+ const rowInstanceId = getInstanceIdFromData(row);
1110
+ if (rowInstanceId)
1111
+ return rowInstanceId;
1112
+ }
1113
+ const fallback = defaultInstanceId(resource);
1114
+ if (fallback)
1115
+ return fallback;
1116
+ throw new CliError("Missing --instance for upload target", 2);
1117
+ };
1118
+ var applyUploadedMediaData = (resource, data, upload) => {
1119
+ if (!upload.fileUrl)
1120
+ return;
1121
+ if (resource.name === "internal-knowledge") {
1122
+ data.sourceType = "UPLOAD";
1123
+ data.url = upload.fileUrl;
1124
+ data.mimeType = upload.contentType;
1125
+ data.size = upload.size;
1126
+ return;
1127
+ }
1128
+ if (resource.name === "resources") {
1129
+ data.sourceType = "UPLOAD";
1130
+ data.fileUrl = upload.fileUrl;
1131
+ data.linkUrl = upload.fileUrl;
1132
+ }
1133
+ };
1134
+ var setUploadInstanceData = (resource, data, instanceId) => {
1135
+ const instanceField = resource.instanceField === undefined ? "instanceId" : resource.instanceField;
1136
+ if (instanceField && !instanceField.includes(".")) {
1137
+ data[instanceField] = instanceId;
1138
+ }
1139
+ };
1140
+ var uploadToSignedUrl = async (signedUrl, filePath, contentType, size) => {
1141
+ const response = await fetch(signedUrl, {
1142
+ method: "PUT",
1143
+ body: createReadStream(filePath),
1144
+ duplex: "half",
1145
+ headers: {
1146
+ "Content-Type": contentType,
1147
+ "Content-Length": String(size)
1148
+ }
1149
+ });
1150
+ if (!response.ok) {
1151
+ throw new CliError(`Direct upload failed with ${response.status}`, 1);
1152
+ }
1153
+ };
1154
+ var isSignedUploadResult = (value) => {
1155
+ if (!value || typeof value !== "object")
1156
+ return false;
1157
+ const upload = value;
1158
+ return typeof upload.signedUrl === "string" && typeof upload.fileUrl === "string" && typeof upload.filePath === "string" && typeof upload.contentType === "string" && typeof upload.instanceId === "string";
1159
+ };
1160
+ var isPreparedSignedUpload = (value) => {
1161
+ if (!value || typeof value !== "object")
1162
+ return false;
1163
+ const upload = value;
1164
+ return typeof upload.signedUrl === "string" && typeof upload.fileUrl === "string" && typeof upload.filePath === "string" && typeof upload.contentType === "string" && typeof upload.size === "number" && typeof upload.instanceId === "string";
1165
+ };
1166
+ var getInstanceIdFromData = (value) => {
1167
+ if (!value || typeof value !== "object" || Array.isArray(value))
1168
+ return null;
1169
+ const row = value;
1170
+ const instanceId = row.instanceId ?? row.instanceID;
1171
+ return typeof instanceId === "string" && instanceId.length > 0 ? instanceId : null;
1172
+ };
1173
+ var resolveLocalPath = (filePath) => {
1174
+ if (filePath === "~")
1175
+ return homedir2();
1176
+ if (filePath.startsWith("~/"))
1177
+ return join2(homedir2(), filePath.slice(2));
1178
+ return resolve(filePath);
1179
+ };
1180
+ var inferMimeType = (filePath) => {
1181
+ const ext = extname(filePath).toLowerCase();
1182
+ const mimeByExtension = {
1183
+ ".mp4": "video/mp4",
1184
+ ".m4v": "video/mp4",
1185
+ ".mov": "video/quicktime",
1186
+ ".webm": "video/webm",
1187
+ ".pdf": "application/pdf",
1188
+ ".txt": "text/plain",
1189
+ ".md": "text/markdown",
1190
+ ".html": "text/html",
1191
+ ".htm": "text/html",
1192
+ ".doc": "application/msword",
1193
+ ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
1194
+ };
1195
+ return mimeByExtension[ext] ?? "application/octet-stream";
1196
+ };
972
1197
  var getSoftDeleteData = (resource) => {
973
1198
  if (resource.defaultFields.includes("disabled"))
974
1199
  return { disabled: true };
@@ -1616,7 +1841,10 @@ var runImportedSheetsCommand = async (action, importedSheetId, ctx) => {
1616
1841
  "attach-page",
1617
1842
  "set-source",
1618
1843
  "delete",
1619
- "runs"
1844
+ "runs",
1845
+ "connect-google",
1846
+ "oauth",
1847
+ "reconnect-google"
1620
1848
  ].includes(action);
1621
1849
  if (needsInstance && !instanceId)
1622
1850
  throw new CliError("Missing --instance", 2);
@@ -1701,10 +1929,10 @@ var runImportedSheetsCommand = async (action, importedSheetId, ctx) => {
1701
1929
  };
1702
1930
  if (hasFlag(ctx, "dry-run"))
1703
1931
  return { operation: "imported-sheets.set-source", importedSheetId, ...payload };
1704
- return requestApi(`/api/cli/imported-sheets/${importedSheetId}/source`, {
1932
+ return requestImportedSheetApi(ctx, instanceId, "set-source", () => requestApi(`/api/cli/imported-sheets/${importedSheetId}/source`, {
1705
1933
  method: "POST",
1706
1934
  body: JSON.stringify(payload)
1707
- });
1935
+ }));
1708
1936
  }
1709
1937
  if (action === "runs") {
1710
1938
  const searchParams = importedSheetSearchParams(ctx);
@@ -1715,10 +1943,13 @@ var runImportedSheetsCommand = async (action, importedSheetId, ctx) => {
1715
1943
  const sourceInput = getStringFlag(ctx, "source");
1716
1944
  if (!sourceInput)
1717
1945
  throw new CliError("Missing --source", 2);
1718
- return requestApi("/api/cli/imported-sheets/resolve", {
1946
+ return requestImportedSheetApi(ctx, instanceId, "resolve", () => requestApi("/api/cli/imported-sheets/resolve", {
1719
1947
  method: "POST",
1720
1948
  body: JSON.stringify({ instanceId, sourceInput })
1721
- });
1949
+ }));
1950
+ }
1951
+ if (action === "connect-google" || action === "oauth" || action === "reconnect-google") {
1952
+ return openImportedSheetGoogleOAuthHandoff(ctx, instanceId, getStringFlag(ctx, "owner-email") ?? getStringFlag(ctx, "account-email"));
1722
1953
  }
1723
1954
  if (["create", "update", "sync", "enable-locales", "translate", "retranslate", "replace-grid", "patch-cells", "vectorize", "repair-french", "delete"].includes(action)) {
1724
1955
  requireWriteConfirmation("Imported sheet operation writes production data. Add --yes or use --dry-run.", ctx);
@@ -1727,27 +1958,34 @@ var runImportedSheetsCommand = async (action, importedSheetId, ctx) => {
1727
1958
  const payload = await importedSheetCreatePayload(ctx);
1728
1959
  if (hasFlag(ctx, "dry-run"))
1729
1960
  return { dryRun: true, operation: "imported-sheets.create", payload };
1730
- return requestApi("/api/cli/imported-sheets", {
1961
+ return requestImportedSheetApi(ctx, instanceId, "create", () => requestApi("/api/cli/imported-sheets", {
1731
1962
  method: "POST",
1732
1963
  body: JSON.stringify(payload)
1733
- });
1964
+ }), importedSheetOwnerEmailFromPayload(payload));
1734
1965
  }
1735
1966
  if (!importedSheetId)
1736
1967
  throw new CliError("Missing imported sheet id", 2);
1737
1968
  if (action === "update") {
1969
+ const data = await parseJsonObjectFlag(ctx, "data", "data-file");
1970
+ const ownerUserId = getStringFlag(ctx, "owner-user") ?? getStringFlag(ctx, "owner-user-id");
1971
+ const ownerEmail = getStringFlag(ctx, "owner-email") ?? getStringFlag(ctx, "account-email");
1972
+ if (ownerUserId)
1973
+ data.ownerUserId = ownerUserId;
1974
+ if (ownerEmail)
1975
+ data.ownerEmail = ownerEmail;
1738
1976
  const payload = {
1739
1977
  instanceId,
1740
- data: await parseJsonObjectFlag(ctx, "data", "data-file"),
1978
+ data,
1741
1979
  dryRun: hasFlag(ctx, "dry-run")
1742
1980
  };
1743
1981
  if (Object.keys(payload.data).length === 0)
1744
1982
  throw new CliError("Missing --data or --data-file JSON", 2);
1745
1983
  if (hasFlag(ctx, "dry-run"))
1746
1984
  return { operation: "imported-sheets.update", importedSheetId, ...payload };
1747
- return requestApi(`/api/cli/imported-sheets/${importedSheetId}`, {
1985
+ return requestImportedSheetApi(ctx, instanceId, "update", () => requestApi(`/api/cli/imported-sheets/${importedSheetId}`, {
1748
1986
  method: "PATCH",
1749
1987
  body: JSON.stringify(payload)
1750
- });
1988
+ }), importedSheetOwnerEmailFromPayload(data));
1751
1989
  }
1752
1990
  if (action === "sync") {
1753
1991
  const payload = {
@@ -1757,10 +1995,10 @@ var runImportedSheetsCommand = async (action, importedSheetId, ctx) => {
1757
1995
  };
1758
1996
  if (hasFlag(ctx, "dry-run"))
1759
1997
  return { operation: "imported-sheets.sync", importedSheetId, ...payload };
1760
- return requestApi(`/api/cli/imported-sheets/${importedSheetId}/sync`, {
1998
+ return requestImportedSheetApi(ctx, instanceId, "sync", () => requestApi(`/api/cli/imported-sheets/${importedSheetId}/sync`, {
1761
1999
  method: "POST",
1762
2000
  body: JSON.stringify(payload)
1763
- });
2001
+ }));
1764
2002
  }
1765
2003
  if (action === "enable-locales" || action === "translate") {
1766
2004
  const locales = splitCsv(getStringFlag(ctx, "locales") ?? getStringFlag(ctx, "languages") ?? getStringFlag(ctx, "to"));
@@ -1776,10 +2014,10 @@ var runImportedSheetsCommand = async (action, importedSheetId, ctx) => {
1776
2014
  };
1777
2015
  if (hasFlag(ctx, "dry-run"))
1778
2016
  return { operation: `imported-sheets.${action}`, importedSheetId, ...payload };
1779
- return requestApi(`/api/cli/imported-sheets/${importedSheetId}/translate`, {
2017
+ return requestImportedSheetApi(ctx, instanceId, action, () => requestApi(`/api/cli/imported-sheets/${importedSheetId}/translate`, {
1780
2018
  method: "POST",
1781
2019
  body: JSON.stringify(payload)
1782
- });
2020
+ }));
1783
2021
  }
1784
2022
  if (action === "retranslate") {
1785
2023
  const locales = splitCsv(getStringFlag(ctx, "locales") ?? getStringFlag(ctx, "languages") ?? getStringFlag(ctx, "to"));
@@ -1797,10 +2035,10 @@ var runImportedSheetsCommand = async (action, importedSheetId, ctx) => {
1797
2035
  };
1798
2036
  if (hasFlag(ctx, "dry-run"))
1799
2037
  return { operation: "imported-sheets.retranslate", importedSheetId, ...payload };
1800
- return requestApi(`/api/cli/imported-sheets/${importedSheetId}/retranslate`, {
2038
+ return requestImportedSheetApi(ctx, instanceId, "retranslate", () => requestApi(`/api/cli/imported-sheets/${importedSheetId}/retranslate`, {
1801
2039
  method: "POST",
1802
2040
  body: JSON.stringify(payload)
1803
- });
2041
+ }));
1804
2042
  }
1805
2043
  if (action === "replace-grid") {
1806
2044
  const locale = getStringFlag(ctx, "locale") ?? getStringFlag(ctx, "language");
@@ -1819,10 +2057,10 @@ var runImportedSheetsCommand = async (action, importedSheetId, ctx) => {
1819
2057
  };
1820
2058
  if (hasFlag(ctx, "dry-run"))
1821
2059
  return { operation: "imported-sheets.replace-grid", importedSheetId, ...payload };
1822
- return requestApi(`/api/cli/imported-sheets/${importedSheetId}/replace-grid`, {
2060
+ return requestImportedSheetApi(ctx, instanceId, "replace-grid", () => requestApi(`/api/cli/imported-sheets/${importedSheetId}/replace-grid`, {
1823
2061
  method: "POST",
1824
2062
  body: JSON.stringify(payload)
1825
- });
2063
+ }));
1826
2064
  }
1827
2065
  if (action === "patch-cells") {
1828
2066
  const data = await parseJsonObjectFlag(ctx, "data", "data-file");
@@ -1837,10 +2075,10 @@ var runImportedSheetsCommand = async (action, importedSheetId, ctx) => {
1837
2075
  cacheScope: getStringFlag(ctx, "cache-scope") ?? data.cacheScope,
1838
2076
  dryRun: hasFlag(ctx, "dry-run")
1839
2077
  };
1840
- return requestApi(`/api/cli/imported-sheets/${importedSheetId}/patch-cells`, {
2078
+ return requestImportedSheetApi(ctx, instanceId, "patch-cells", () => requestApi(`/api/cli/imported-sheets/${importedSheetId}/patch-cells`, {
1841
2079
  method: "POST",
1842
2080
  body: JSON.stringify(payload)
1843
- });
2081
+ }));
1844
2082
  }
1845
2083
  if (action === "vectorize") {
1846
2084
  const payload = {
@@ -1850,10 +2088,10 @@ var runImportedSheetsCommand = async (action, importedSheetId, ctx) => {
1850
2088
  };
1851
2089
  if (hasFlag(ctx, "dry-run"))
1852
2090
  return { operation: "imported-sheets.vectorize", importedSheetId, ...payload };
1853
- return requestApi(`/api/cli/imported-sheets/${importedSheetId}/vectorize`, {
2091
+ return requestImportedSheetApi(ctx, instanceId, "vectorize", () => requestApi(`/api/cli/imported-sheets/${importedSheetId}/vectorize`, {
1854
2092
  method: "POST",
1855
2093
  body: JSON.stringify(payload)
1856
- });
2094
+ }));
1857
2095
  }
1858
2096
  if (action === "repair-french") {
1859
2097
  const payload = {
@@ -1864,10 +2102,10 @@ var runImportedSheetsCommand = async (action, importedSheetId, ctx) => {
1864
2102
  };
1865
2103
  if (hasFlag(ctx, "dry-run"))
1866
2104
  return { operation: "imported-sheets.repair-french", importedSheetId, ...payload };
1867
- return requestApi(`/api/cli/imported-sheets/${importedSheetId}/repair-french`, {
2105
+ return requestImportedSheetApi(ctx, instanceId, "repair-french", () => requestApi(`/api/cli/imported-sheets/${importedSheetId}/repair-french`, {
1868
2106
  method: "POST",
1869
2107
  body: JSON.stringify(payload)
1870
- });
2108
+ }));
1871
2109
  }
1872
2110
  if (action === "delete") {
1873
2111
  const expectedConfirmation = `imported-sheets:${importedSheetId}`;
@@ -2088,9 +2326,82 @@ var importedSheetSearchParams = (ctx) => {
2088
2326
  searchParams.set("pageSize", pageSize);
2089
2327
  return searchParams;
2090
2328
  };
2329
+ var requestImportedSheetApi = async (ctx, instanceId, operation, request, ownerEmail) => {
2330
+ try {
2331
+ return await request();
2332
+ } catch (error) {
2333
+ if (!isCliError(error) || !isGoogleSheetsPermissionError(error.message))
2334
+ throw error;
2335
+ const handoff = await runImportedSheetGoogleOAuth(ctx, instanceId, ownerEmail);
2336
+ if (handoff.waited) {
2337
+ return request();
2338
+ }
2339
+ throw new CliError(error.message, error.exitCode, {
2340
+ ...error.details ?? {},
2341
+ googleOAuth: {
2342
+ ...handoff,
2343
+ operation,
2344
+ retry: "Complete the browser Google flow, then run the same CLI command again."
2345
+ }
2346
+ });
2347
+ }
2348
+ };
2349
+ var runImportedSheetGoogleOAuth = async (ctx, instanceId, ownerEmail) => {
2350
+ if (hasFlag(ctx, "dry-run") || hasFlag(ctx, "no-open") || hasFlag(ctx, "no-oauth-wait")) {
2351
+ return openImportedSheetGoogleOAuthHandoff(ctx, instanceId, ownerEmail);
2352
+ }
2353
+ const session = await getApiSession();
2354
+ const timeoutMs = getNumberFlag(ctx, "oauth-timeout-ms") ?? 5 * 60 * 1000;
2355
+ const result = await waitForGoogleSheetsOAuth({
2356
+ baseUrl: session.baseUrl,
2357
+ instanceId,
2358
+ ownerEmail,
2359
+ lang: getStringFlag(ctx, "lang") ?? getStringFlag(ctx, "language") ?? "fr",
2360
+ timeoutMs
2361
+ });
2362
+ return {
2363
+ operation: "imported-sheets.connect-google",
2364
+ instanceId,
2365
+ opened: true,
2366
+ waited: true,
2367
+ connected: result.connected,
2368
+ userEmail: result.userEmail,
2369
+ note: "Google Sheets access was granted in the browser.",
2370
+ retry: "OAuth completed in the browser. Retrying the CLI operation now."
2371
+ };
2372
+ };
2373
+ var openImportedSheetGoogleOAuthHandoff = async (ctx, instanceId, ownerEmail) => {
2374
+ const url = await buildImportedSheetGoogleOAuthUrl(ctx, instanceId, ownerEmail);
2375
+ const opened = hasFlag(ctx, "dry-run") || hasFlag(ctx, "no-open") ? false : await openUrl(url);
2376
+ return {
2377
+ operation: "imported-sheets.connect-google",
2378
+ instanceId,
2379
+ url,
2380
+ opened,
2381
+ waited: false,
2382
+ note: "This opens the GSkills browser flow that asks Google for Sheets access. The browser user must be the owner account you pass to imported-sheets create/update."
2383
+ };
2384
+ };
2385
+ var buildImportedSheetGoogleOAuthUrl = async (ctx, instanceId, ownerEmail) => {
2386
+ const baseUrl = getStringFlag(ctx, "base-url") ?? process.env.GSKILLS_CLI_BASE_URL ?? (hasFlag(ctx, "dry-run") ? "https://g-skills.fr" : (await getApiSession()).baseUrl);
2387
+ const lang = getStringFlag(ctx, "lang") ?? getStringFlag(ctx, "language") ?? "fr";
2388
+ const reconnectUrl = new URL(`/${lang}/super-admin/${instanceId}/imported-sheets`, baseUrl);
2389
+ reconnectUrl.searchParams.set("googleSheetsOAuth", "1");
2390
+ if (ownerEmail)
2391
+ reconnectUrl.searchParams.set("ownerEmail", ownerEmail);
2392
+ return reconnectUrl.toString();
2393
+ };
2394
+ var importedSheetOwnerEmailFromPayload = (payload) => getObjectString(payload, "ownerEmail") ?? getObjectString(payload, "accountEmail") ?? getObjectString(payload, "googleAccountEmail");
2395
+ var isGoogleSheetsPermissionError = (message) => {
2396
+ const normalized = message.toLowerCase();
2397
+ return normalized.includes("google sheets permission is missing") || normalized.includes("google account not connected") || normalized.includes("grant sheets access");
2398
+ };
2091
2399
  var importedSheetCreatePayload = async (ctx) => {
2092
2400
  const data = await parseJsonObjectFlag(ctx, "data", "data-file");
2093
2401
  if (Object.keys(data).length > 0) {
2402
+ if (!hasImportedSheetOwnerInput(data)) {
2403
+ throw new CliError("Imported sheet creation needs a Google owner account. Pass ownerEmail/ownerUserId in --data or use --owner-email / --owner-user.", 2);
2404
+ }
2094
2405
  return {
2095
2406
  ...data,
2096
2407
  dryRun: hasFlag(ctx, "dry-run")
@@ -2105,6 +2416,11 @@ var importedSheetCreatePayload = async (ctx) => {
2105
2416
  throw new CliError("Missing --source", 2);
2106
2417
  if (!tabName)
2107
2418
  throw new CliError("Missing --tab", 2);
2419
+ const ownerUserId = getStringFlag(ctx, "owner-user") ?? getStringFlag(ctx, "owner-user-id");
2420
+ const ownerEmail = getStringFlag(ctx, "owner-email") ?? getStringFlag(ctx, "account-email");
2421
+ if (!ownerUserId && !ownerEmail) {
2422
+ throw new CliError("Imported sheet creation needs a Google owner account. Pass --owner-email or --owner-user.", 2);
2423
+ }
2108
2424
  return {
2109
2425
  instanceId,
2110
2426
  displayName: getStringFlag(ctx, "display-name"),
@@ -2115,11 +2431,18 @@ var importedSheetCreatePayload = async (ctx) => {
2115
2431
  sourceInput,
2116
2432
  tabName
2117
2433
  },
2434
+ ownerUserId,
2435
+ ownerEmail,
2118
2436
  enableVectorization: hasFlag(ctx, "enable-vectorization"),
2119
2437
  vectorHeaders: splitCsv(getStringFlag(ctx, "vector-headers") ?? getStringFlag(ctx, "vector-columns")),
2120
2438
  dryRun: hasFlag(ctx, "dry-run")
2121
2439
  };
2122
2440
  };
2441
+ var hasImportedSheetOwnerInput = (data) => Boolean(getObjectString(data, "ownerUserId") || getObjectString(data, "ownerUser") || getObjectString(data, "accountUserId") || getObjectString(data, "ownerEmail") || getObjectString(data, "accountEmail") || getObjectString(data, "googleAccountEmail"));
2442
+ var getObjectString = (data, key) => {
2443
+ const value = data[key];
2444
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
2445
+ };
2123
2446
  var splitCsv = (value) => value ? value.split(",").map((item) => item.trim()).filter(Boolean) : [];
2124
2447
  var setWhereValue = (where, fieldPath, value) => {
2125
2448
  const parts = fieldPath.split(".").map((part) => part.trim()).filter(Boolean);
@@ -2225,7 +2548,9 @@ var rootHelp = () => ({
2225
2548
  "gskills-admin sync run --target <instanceId> --only pages,quizzes --yes",
2226
2549
  "gskills-admin sync repair-source-links --target <instanceId> --dry-run",
2227
2550
  "gskills-admin translate pages <id> --to en,es --dry-run",
2228
- "gskills-admin imported-sheets create --instance <id> --source <url> --tab <name> --locales fr,en --enable-vectorization --dry-run",
2551
+ "gskills-admin imported-sheets create --instance <id> --source <url> --tab <name> --default-locale en --locales fr,en --owner-email admin@example.com --enable-vectorization --dry-run",
2552
+ `gskills-admin internal-knowledge create --instance <instanceId> --upload-file ./video.mp4 --data '{"title":"...","language":"fr"}' --yes`,
2553
+ `gskills-admin resources create --instance <instanceId> --upload-file ./webinar.mp4 --data '{"title":"...","type":"WEBINAR","language":"fr"}' --yes`,
2229
2554
  "gskills-admin internal-knowledge sync-media --since today --languages fr --all-targets --dry-run",
2230
2555
  "gskills-admin progress learning-path-quiz-mismatches --instance <instanceId>",
2231
2556
  "gskills-admin sessions invalidate --email user@example.com --dry-run",
@@ -2268,9 +2593,10 @@ var schemaHelp = () => ({
2268
2593
  { name: "imported-sheets locales", args: ["id"], required: ["--instance"], writes: false },
2269
2594
  { name: "imported-sheets runs", args: ["id?"], required: ["--instance"], flags: ["--take"], writes: false },
2270
2595
  { name: "imported-sheets resolve", required: ["--instance", "--source"], writes: false },
2271
- { name: "imported-sheets create", required: ["--instance", "--source", "--tab"], flags: ["--display-name", "--locales", "--mode", "--enable-vectorization", "--vector-headers", "--data", "--data-file", "--yes", "--dry-run"], writes: true },
2272
- { name: "imported-sheets update", args: ["id"], required: ["--instance", "--data or --data-file"], flags: ["--yes", "--dry-run"], writes: true },
2273
- { name: "imported-sheets sync", args: ["id"], required: ["--instance"], flags: ["--locales", "--yes", "--dry-run"], writes: true },
2596
+ { name: "imported-sheets connect-google", required: ["--instance"], flags: ["--base-url", "--lang", "--owner-email", "--no-open", "--dry-run"], writes: false },
2597
+ { name: "imported-sheets create", required: ["--instance", "--source", "--tab", "--owner-email or --owner-user"], flags: ["--display-name", "--locales", "--mode", "--default-locale", "--owner-email", "--owner-user", "--enable-vectorization", "--vector-headers", "--data", "--data-file", "--oauth-timeout-ms", "--no-oauth-wait", "--yes", "--dry-run"], writes: true },
2598
+ { name: "imported-sheets update", args: ["id"], required: ["--instance", "--data or --data-file or --owner-email"], flags: ["--owner-email", "--owner-user", "--oauth-timeout-ms", "--no-oauth-wait", "--yes", "--dry-run"], writes: true },
2599
+ { name: "imported-sheets sync", args: ["id"], required: ["--instance"], flags: ["--locales", "--oauth-timeout-ms", "--no-oauth-wait", "--yes", "--dry-run"], writes: true },
2274
2600
  { name: "imported-sheets enable-locales", args: ["id"], required: ["--instance", "--locales"], flags: ["--yes", "--dry-run"], writes: true },
2275
2601
  { name: "imported-sheets translate", args: ["id"], required: ["--instance", "--to"], flags: ["--yes", "--dry-run"], writes: true },
2276
2602
  { name: "imported-sheets retranslate", args: ["id"], required: ["--instance", "--to"], flags: ["--from", "--revectorize", "--yes", "--dry-run"], writes: true },
@@ -2314,8 +2640,8 @@ var schemaHelp = () => ({
2314
2640
  ...resources.flatMap((resource) => [
2315
2641
  { name: `${resource.name} list`, writes: false, flags: ["--where", "--fields", "--take", "--skip", "--order-by", "--instance", "--dry-run"] },
2316
2642
  { name: `${resource.name} get`, args: ["id"], writes: false },
2317
- { name: `${resource.name} create`, flags: ["--data", "--instance", "--dry-run"], writes: true },
2318
- { name: `${resource.name} update`, args: ["id"], flags: ["--data", "--dry-run"], writes: true },
2643
+ { name: `${resource.name} create`, flags: ["--data", "--instance", ...UPLOADABLE_RESOURCE_NAMES.has(resource.name) ? ["--upload-file", "--upload-name", "--mime-type"] : [], "--dry-run"], writes: true },
2644
+ { name: `${resource.name} update`, args: ["id"], flags: ["--data", "--instance", ...UPLOADABLE_RESOURCE_NAMES.has(resource.name) ? ["--upload-file", "--upload-name", "--mime-type"] : [], "--dry-run"], writes: true },
2319
2645
  { name: `${resource.name} delete`, args: ["id"], flags: ["--force", "--confirm-delete", "--dry-run"], writes: true, destructive: false, softOnly: true }
2320
2646
  ])
2321
2647
  ],
@@ -2413,8 +2739,10 @@ var importedSheetsHelp = () => ({
2413
2739
  usage: [
2414
2740
  "gskills-admin imported-sheets list --instance <instanceId>",
2415
2741
  "gskills-admin imported-sheets get <sheetId> --instance <instanceId> --locale en --page-size 100",
2742
+ "gskills-admin imported-sheets connect-google --instance <instanceId> --base-url https://g-skills.fr",
2416
2743
  "gskills-admin imported-sheets resolve --instance <instanceId> --source <sheet-url>",
2417
- "gskills-admin imported-sheets create --instance <instanceId> --source <sheet-url> --tab 'Cas d’usage' --display-name 'Cas d’usage Gemini' --locales fr,en,es --enable-vectorization --vector-headers 'Titre,Description,Prompt' --dry-run",
2744
+ "gskills-admin imported-sheets create --instance <instanceId> --source <sheet-url> --tab EN --default-locale en --display-name 'Use cases' --locales fr,en --owner-email admin@example.com --enable-vectorization --vector-headers 'Use case,Description,Full prompt' --dry-run",
2745
+ "gskills-admin imported-sheets update <sheetId> --instance <instanceId> --owner-email admin@example.com --dry-run",
2418
2746
  "gskills-admin imported-sheets update <sheetId> --instance <instanceId> --data-file ./settings.json --dry-run",
2419
2747
  "gskills-admin imported-sheets sync <sheetId> --instance <instanceId> --dry-run",
2420
2748
  "gskills-admin imported-sheets translate <sheetId> --instance <instanceId> --to en,es --dry-run",
@@ -2429,6 +2757,7 @@ var importedSheetsHelp = () => ({
2429
2757
  "gskills-admin imported-sheets delete <sheetId> --instance <instanceId> --force --confirm-delete imported-sheets:<sheetId> --dry-run"
2430
2758
  ],
2431
2759
  writes: "create, update, sync, translate, retranslate, replace-grid, patch-cells, vectorize, repair-french, copy-to, attach-page, set-source and delete require --yes or --dry-run.",
2760
+ oauth: "When Google Sheets access is missing, create/update/sync open the browser OAuth flow, wait for completion, then retry automatically. Use --no-oauth-wait to only print/open the reconnect URL.",
2432
2761
  patchCellsDataShape: {
2433
2762
  patches: [
2434
2763
  {
@@ -2451,12 +2780,14 @@ var importedSheetsHelp = () => ({
2451
2780
  enabledLocales: ["fr", "en", "es"],
2452
2781
  multilangMode: "AI_TRANSLATION",
2453
2782
  defaultLocaleSource: { locale: "fr", sourceInput: "https://docs.google.com/spreadsheets/d/...", tabName: "FR" },
2454
- localeSources: [{ locale: "en", sourceInput: "https://docs.google.com/spreadsheets/d/...", tabName: "EN" }],
2783
+ localeSources: [{ locale: "fr", sourceInput: "https://docs.google.com/spreadsheets/d/...", tabName: "FR" }],
2784
+ ownerEmail: "admin@example.com",
2455
2785
  enableVectorization: true,
2456
2786
  vectorHeaders: ["Titre", "Description", "Prompt"]
2457
2787
  },
2458
2788
  updateDataShape: {
2459
2789
  displayName: "Cas d'usage Gemini",
2790
+ ownerEmail: "admin@example.com",
2460
2791
  viewMode: "LINE",
2461
2792
  enableVectorization: true,
2462
2793
  columns: [{ id: "column_id", isVisible: true, includeInVectorization: true, displayType: "TITLE", showLabel: false, displayOrder: 0 }],
@@ -2602,6 +2933,8 @@ var resourceHelp = (resource) => ({
2602
2933
  `gskills-admin ${resource.name} create --data '{"instanceId":"global"}'`,
2603
2934
  `gskills-admin ${resource.name} update <id> --data '{"disabled":true}'`,
2604
2935
  `gskills-admin ${resource.name} delete <id> --force --confirm-delete ${resource.name}:<id>`,
2936
+ ...resource.name === "internal-knowledge" ? [`gskills-admin ${resource.name} create --instance <instanceId> --upload-file ./video.mp4 --data '{"title":"Video","language":"fr","isActive":true}' --dry-run`] : [],
2937
+ ...resource.name === "resources" ? [`gskills-admin ${resource.name} create --instance <instanceId> --upload-file ./webinar.mp4 --data '{"title":"Webinar","type":"WEBINAR","language":"fr","isActive":true}' --dry-run`] : [],
2605
2938
  ...resource.name === "internal-knowledge" ? [`gskills-admin ${resource.name} sync-media --since today --languages fr --all-targets --dry-run`] : [],
2606
2939
  ...resource.name === "pages" ? [`gskills-admin ${resource.name} backfill-field --field headerColor --all-targets --dry-run`] : []
2607
2940
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@numericoach/gskills-admin-cli",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin-only CLI for GSkills super-admin operations.",
@@ -13,6 +13,7 @@ Also install and use the companion skills:
13
13
 
14
14
  - `gskills-vocabulary` when explaining work to admins or writing user-facing summaries.
15
15
  - `gskills-customer-playbooks` when the task names a recurring GSkills customer.
16
+ - `gskills-admin-cli-publishing` when publishing the npm package or sharing the publish recipe with another teammate.
16
17
 
17
18
  ## Install
18
19
 
@@ -69,6 +70,17 @@ gskills-admin cache invalidate --instance <instanceId> --scope pages --yes --out
69
70
 
70
71
  CRUD help exposes `cache.scopes` for resources that are known to feed deploy caches. After create, update, or soft-delete, the database can be correct while the end-user view is still stale. Use the narrowest listed scope first. Use `all` only when the changed setting affects many deploy surfaces or when the narrow scope did not clear the visible stale state.
71
72
 
73
+ Internal knowledge and resources support direct local file uploads through signed GCS URLs. The CLI gets a signed URL from the authenticated app API, streams the local file directly to storage, then writes the normal row with the returned URL. This avoids routing large videos through a Next.js API body.
74
+
75
+ ```bash
76
+ gskills-admin internal-knowledge create --instance dev-numericoach --upload-file ./capsule.mp4 --data '{"title":"Capsule test","language":"fr","isActive":true,"isAIAllowed":false}' --dry-run --output json
77
+ gskills-admin internal-knowledge update <knowledgeId> --instance dev-numericoach --upload-file ./capsule-v2.mp4 --data '{}' --dry-run --output json
78
+ gskills-admin resources create --instance dev-numericoach --upload-file ./webinar.mp4 --data '{"title":"Webinar test","type":"WEBINAR","language":"fr","isActive":true}' --dry-run --output json
79
+ gskills-admin resources update <resourceId> --instance dev-numericoach --upload-file ./webinar-v2.mp4 --data '{}' --dry-run --output json
80
+ ```
81
+
82
+ Use `--mime-type` when the extension is ambiguous and `--upload-name` when the stored file name should differ from the local basename. Always pass `--instance` for client-specific content; otherwise content-like creates default to `global`.
83
+
72
84
  Delete commands are soft-only. They require both `--force` and an exact confirmation token, then write the safest inactive field available, such as `disabled: true`, `archived: true`, `isActive: false`, or `active: false`. If a resource cannot be safely disabled, the CLI refuses the delete command.
73
85
 
74
86
  ```bash
@@ -0,0 +1,84 @@
1
+ ---
2
+ name: gskills-admin-cli-publishing
3
+ description: Use when publishing the @numericoach/gskills-admin-cli npm package or refreshing the team publish recipe.
4
+ ---
5
+
6
+ # GSkills Admin CLI Publishing
7
+
8
+ Use this skill when publishing `@numericoach/gskills-admin-cli`.
9
+
10
+ The package lives in `packages/gskills-admin-cli`. It is public, but publishing still needs a Numericoach npm token with publish rights.
11
+
12
+ ## Token Storage
13
+
14
+ Never commit an npm token and never write it into a repo `.npmrc`.
15
+
16
+ On macOS, store each teammate's own token in Keychain:
17
+
18
+ ```bash
19
+ read -rsp "npm token: " NPM_TOKEN
20
+ printf "\n"
21
+ security add-generic-password \
22
+ -s numericoach-npm-publish-token \
23
+ -a registry.npmjs.org \
24
+ -w "$NPM_TOKEN" \
25
+ -U
26
+ unset NPM_TOKEN
27
+ ```
28
+
29
+ Check that the Keychain item exists without printing the token:
30
+
31
+ ```bash
32
+ security find-generic-password \
33
+ -s numericoach-npm-publish-token \
34
+ -a registry.npmjs.org >/dev/null
35
+ ```
36
+
37
+ ## Publish Flow
38
+
39
+ From the repo root:
40
+
41
+ ```bash
42
+ npm view @numericoach/gskills-admin-cli version --registry=https://registry.npmjs.org/
43
+ ```
44
+
45
+ Bump `packages/gskills-admin-cli/package.json` to the next patch version.
46
+
47
+ Build and inspect the package:
48
+
49
+ ```bash
50
+ cd packages/gskills-admin-cli
51
+ bun run build
52
+ node dist/gskills-admin.js schema --output json >/tmp/gskills-admin-schema.json
53
+ bun pm pack --dry-run
54
+ ```
55
+
56
+ Publish with a temporary npm config generated from Keychain:
57
+
58
+ ```bash
59
+ cd packages/gskills-admin-cli
60
+ NPM_TOKEN="$(security find-generic-password -s numericoach-npm-publish-token -a registry.npmjs.org -w)"
61
+ NPM_CONFIG_FILE="$(mktemp)"
62
+ trap 'rm -f "$NPM_CONFIG_FILE"' EXIT
63
+ {
64
+ printf 'registry=https://registry.npmjs.org/\n'
65
+ printf '//registry.npmjs.org/:_authToken=%s\n' "$NPM_TOKEN"
66
+ } > "$NPM_CONFIG_FILE"
67
+ unset NPM_TOKEN
68
+ NPM_CONFIG_USERCONFIG="$NPM_CONFIG_FILE" npm whoami
69
+ NPM_CONFIG_USERCONFIG="$NPM_CONFIG_FILE" npm publish --access public
70
+ ```
71
+
72
+ Verify the exact version after publish:
73
+
74
+ ```bash
75
+ npm view @numericoach/gskills-admin-cli@<version> version --registry=https://registry.npmjs.org/
76
+ ```
77
+
78
+ ## Rules
79
+
80
+ - Publish from `packages/gskills-admin-cli`, not the app root.
81
+ - Use `NPM_CONFIG_USERCONFIG` with a temp file for publish. Plain `NPM_TOKEN` can be ignored by npm in this setup.
82
+ - Keep the token in the OS credential store, not in shell rc files, repo files, command logs, or documentation.
83
+ - Commit the version bump, bundled skills, README updates, and rebuilt `dist/gskills-admin.js` after validation.
84
+ - Do not call the package published until `npm view @numericoach/gskills-admin-cli@<version> version` returns the new version.