querysub 0.711.0 → 0.713.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.
@@ -20,7 +20,6 @@ alwaysApply: true
20
20
  - USE: `T[]`
21
21
  - NEVER: `Array<T>`
22
22
  - Never try to add dynamic pluralization in the UI, just use an s. If you add dynamic pluralization, if the code ever gets localized, all of your changes have to be undone, and you just made localization much harder.
23
- - Never use the ternary operator. Instead, do this: `x ? y : z` => `x && y || z`.
24
23
  - The site automatically builds and hotreloads. Just save the files. DO NOT try to run any build scripts, because it automatically builds on save. DO NOT RUN "npm run build". DO NOT TRY TO RUN UNIT TESTS. DO NOT TRY TO RUN TESTS.
25
24
  - When checking for if a value lies within a range, compare like so: `start <= pos && pos < end`. Specifically, making the pos in the middle.
26
25
  - Never use non-null assertion operator, instead check the value, and if necessary (because it is accessed in nested functions), use a const variable to preserve the type.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "querysub",
3
- "version": "0.711.0",
3
+ "version": "0.713.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "note1": "note on node-forge fork, see https://github.com/digitalbazaar/forge/issues/744 for details",
@@ -102,8 +102,8 @@ export class ServicesListPage extends qreact.Component {
102
102
  parameters: {
103
103
  key: newServiceId,
104
104
  machineIds: [],
105
- repoUrl: gitInfo.repoUrl,
106
- gitRef: gitInfo.latestRef,
105
+ repoUrl: gitInfo?.repoUrl || "",
106
+ gitRef: gitInfo?.latestRef || "",
107
107
  command: "ping 1.1.1.1",
108
108
  deploy: false,
109
109
  overlapTime: DEFAULT_OVERLAP_TIME,
@@ -32,7 +32,7 @@ async function main() {
32
32
  let controller = new MachineServiceControllerBase();
33
33
  let commitMessage = `emergency update ${formatDateTime(Date.now())}`;
34
34
 
35
- let gitInfo = await controller.getGitInfo();
35
+ let gitInfo = await getGitInfoAssert(controller);
36
36
  console.log(magenta(`Starting emergency update of ${gitInfo.repoUrl}`), {
37
37
  commitMessage,
38
38
  querysubUncommittedFiles: gitInfo.querysubUncommitted.length,
@@ -47,7 +47,7 @@ async function main() {
47
47
  }
48
48
 
49
49
  // Re-read, as publishing querysub updates our package.json, which then needs to be committed here
50
- gitInfo = await controller.getGitInfo();
50
+ gitInfo = await getGitInfoAssert(controller);
51
51
  if (gitInfo.uncommitted.length > 0) {
52
52
  console.log(magenta(`Committing and pushing the service repo (${gitInfo.uncommitted.length} files changed)`));
53
53
  await controller.commitPushService(commitMessage);
@@ -56,7 +56,7 @@ async function main() {
56
56
  }
57
57
 
58
58
  // Re-read, as latestRef must include the commit we just pushed
59
- gitInfo = await controller.getGitInfo();
59
+ gitInfo = await getGitInfoAssert(controller);
60
60
 
61
61
  let serviceIds = await controller.getServiceList();
62
62
  let configs: ServiceConfig[] = [];
@@ -92,4 +92,12 @@ async function main() {
92
92
  console.log(green(`Archives initialized`));
93
93
  }
94
94
 
95
+ async function getGitInfoAssert(controller: MachineServiceControllerBase) {
96
+ let gitInfo = await controller.getGitInfo();
97
+ if (!gitInfo) {
98
+ throw new Error(`Expected git info for the emergency update, but getGitInfo returned undefined because this process is public (isPublic() is true). Run the emergency update without --public, from the repo you deploy from.`);
99
+ }
100
+ return gitInfo;
101
+ }
102
+
95
103
  main().catch(logErrors).finally(() => process.exit());
@@ -1,6 +1,6 @@
1
1
  import { isNodeTrue, list, timeInDay, timeInMinute, timeInSecond } from "socket-function/src/misc";
2
2
  import { getArchives2 } from "../-a-archives/archives2";
3
- import { getDomain } from "../config";
3
+ import { getDomain, isPublic } from "../config";
4
4
  import { archiveJSONT } from "../-a-archives/archivesJSONT";
5
5
  import { SocketFunction } from "socket-function/SocketFunction";
6
6
  import { assertIsManagementUser } from "../diagnostics/managementPages";
@@ -442,6 +442,7 @@ export class MachineServiceControllerBase {
442
442
  return extractType(module, "ServiceConfig");
443
443
  }
444
444
  public async getGitInfo() {
445
+ if (isPublic()) return undefined;
445
446
  let repoUrl = await getGitURLLive();
446
447
  let uncommitted = await getGitUncommitted(".");
447
448
  let latestRef = await getLatestRefOnUpstreamBranch(".");