@git.zone/cli 11.0.1 → 12.0.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/readme.md CHANGED
@@ -2180,10 +2180,18 @@ rather than overwriting a concurrent change. MongoDB (NoSQLDB), ObjectStorage,
2180
2180
  and Elasticsearch data is stored in `.nogit/nosqldbdata`,
2181
2181
  `.nogit/objectstoragedata`, and `.nogit/esdata`, so it stays out of Git.
2182
2182
 
2183
- The `mongodb` service runs the NoSQLDB engine from the digest-pinned
2184
- `code.foss.global/lossless.zone/database` 2.0.0 image (`@lossless.org/nosqldb`
2185
- 10.7.3) as `<project>-nosqldb`. It
2186
- speaks the MongoDB wire protocol, so the `.nogit/env.json` contract
2183
+ The `mongodb` service runs the NoSQLDB engine from the
2184
+ `code.foss.global/lossless.zone/database` 4.0.0 image (`@lossless.org/nosqldb`
2185
+ 10.10.0), pinned by its multi-arch index digest, as `<project>-nosqldb`. Startup
2186
+ pulls the image when it is missing, before its start-up timeout begins. A
2187
+ container that an earlier gitzone release created on another image is recreated
2188
+ on this one with the same `.nogit/nosqldbdata`. The move is one-way: once the
2189
+ new engine has written certain indexes, such as one on a list field, earlier
2190
+ releases cannot open that data again (the changelog lists them), and the engine
2191
+ refuses to start on a copy of the directory, so a copy is no way back. There is
2192
+ no backup route yet: `mongodump` fails against the new engine too, because the
2193
+ engine refuses the `$natural` hint that `mongodump` sends. It speaks the
2194
+ MongoDB wire protocol, so the `.nogit/env.json` contract
2187
2195
  (`MONGODB_URL`, `MONGODB_HOST`, `MONGODB_PORT`, `MONGODB_USER`, `MONGODB_PASS`,
2188
2196
  `MONGODB_NAME`, `MONGODB_AUTH_ENABLED`) is unchanged and consumers need no code
2189
2197
  change. The wire port is published as `127.0.0.1:MONGODB_PORT` only. The
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@git.zone/cli',
6
- version: '11.0.1',
6
+ version: '12.0.0',
7
7
  description: 'A comprehensive CLI tool for enhancing and managing local development workflows with gitzone utilities, focusing on project setup, version control, code formatting, and template management.'
8
8
  }
@@ -26,6 +26,7 @@ export const ownerNpmScopes = [
26
26
  '@fin.cx',
27
27
  '@foss.global',
28
28
  '@freelance-club',
29
+ '@freelance.club',
29
30
  '@freelance.club_private',
30
31
  '@git.zone',
31
32
  '@hard.global',
@@ -53,6 +54,7 @@ export const ownerNpmScopes = [
53
54
  '@servezone_private',
54
55
  '@ship.zone',
55
56
  '@shipzone',
57
+ '@shoppinglist.app',
56
58
  '@signature.digital',
57
59
  '@signup.software',
58
60
  '@signup.software_private',
@@ -590,6 +590,8 @@ export class DockerContainer {
590
590
  private queryTimeoutSeconds = 60;
591
591
  /** Longer bound for root-helper cleanup, which may delete a large tree. */
592
592
  private cleanupTimeoutSeconds = 600;
593
+ /** Bound for pulling an image, which may be large on a slow link. */
594
+ private pullTimeoutSeconds = 30 * 60;
593
595
  private bindOperationDelay = async (millisecondsArg: number): Promise<void> =>
594
596
  plugins.smartpromise.delayFor(millisecondsArg);
595
597
 
@@ -1235,6 +1237,15 @@ export class DockerContainer {
1235
1237
  }
1236
1238
  }
1237
1239
 
1240
+ /** Pulls an image unless it is already present locally. */
1241
+ public async ensureImagePresent(imageArg: string): Promise<void> {
1242
+ if (await this.imageExists(imageArg)) {
1243
+ return;
1244
+ }
1245
+ logger.log('note', ` Pulling ${imageArg}...`);
1246
+ await this.execArgv(['pull', imageArg], { timeoutMs: this.pullTimeoutSeconds * 1_000 });
1247
+ }
1248
+
1238
1249
  /** Exact persisted quarantine path for an interrupted deletion, if present. */
1239
1250
  public async getPendingDataDeletionPath(
1240
1251
  projectPathArg: string,
@@ -1519,11 +1530,14 @@ export class DockerContainer {
1519
1530
  return true;
1520
1531
  }
1521
1532
 
1522
- if (!(await this.imageExists(imageArg))) {
1533
+ try {
1534
+ await this.ensureImagePresent(imageArg);
1535
+ } catch (error) {
1523
1536
  throw new Error(
1524
- `Cannot finish removing quarantined data at ${quarantinePath}: its contents belong to the container user and image ` +
1525
- `${imageArg} is not available locally to perform a root-helper cleanup. ` +
1537
+ `Cannot finish removing quarantined data at ${quarantinePath}: its contents belong to the container user, and image ` +
1538
+ `${imageArg}, which performs the root-helper cleanup, could not be pulled. ` +
1526
1539
  `Pull ${imageArg} and retry; the canonical path remains absent and the deletion intent is preserved.`,
1540
+ { cause: error },
1527
1541
  );
1528
1542
  }
1529
1543
 
@@ -70,6 +70,8 @@ export interface ILegacyMongoMigrationDocker {
70
70
  executionOptionsArg: IDockerExecArgvOptions,
71
71
  ): Promise<IDockerExecArgvResult>;
72
72
  runFencedBindOperation(optionsArg: IFencedBindOperationOptions): Promise<void>;
73
+ /** Pulls an image unless it is already present locally. */
74
+ ensureImagePresent(imageArg: string): Promise<void>;
73
75
  removeDataDirectoryHoldingLock(
74
76
  hostPathArg: string,
75
77
  imageArg: string,
@@ -842,15 +844,6 @@ export class LegacyMongoMigration {
842
844
  }
843
845
  }
844
846
 
845
- private async ensureImagePresent(imageArg: string): Promise<void> {
846
- try {
847
- await this.host.docker.execArgv(['image', 'inspect', imageArg], { timeoutMs: queryTimeoutMs });
848
- } catch {
849
- this.host.log('note', ` Pulling ${imageArg}...`);
850
- await this.host.docker.execArgv(['pull', imageArg], { timeoutMs: toolTimeoutMs });
851
- }
852
- }
853
-
854
847
  private async resolveImageId(imageArg: string): Promise<string> {
855
848
  const result = await this.host.docker.execArgv(
856
849
  ['image', 'inspect', '--format', '{{.Id}}', imageArg],
@@ -867,8 +860,8 @@ export class LegacyMongoMigration {
867
860
  const config = this.host.config;
868
861
  this.host.log('note', ' Legacy MongoDB data found; migrating it to NoSQLDB...');
869
862
  // Every image must be present before the legacy database is touched.
870
- await this.ensureImagePresent(noSqlDbImage);
871
- await this.ensureImagePresent(legacyMongoImage);
863
+ await this.host.docker.ensureImagePresent(noSqlDbImage);
864
+ await this.host.docker.ensureImagePresent(legacyMongoImage);
872
865
  // The reader opens the data with the exact image the legacy mongod ran.
873
866
  const readerImageId = sourceArg.container?.imageId ?? (await this.resolveImageId(legacyMongoImage));
874
867
  await recordLegacyServiceDataDirectory(this.projectPath, 'mongo');
@@ -19,11 +19,13 @@ export const objectStorageImage =
19
19
 
20
20
  /**
21
21
  * NoSQLDB engine image serving the `mongodb` service:
22
- * `code.foss.global/lossless.zone/database` 2.0.0 (@lossless.org/nosqldb
23
- * 10.7.3), multi-arch index digest for linux/amd64 and linux/arm64.
22
+ * `code.foss.global/lossless.zone/database` 4.0.0 (@lossless.org/nosqldb
23
+ * 10.10.0). The digest is the multi-arch index for linux/amd64 and
24
+ * linux/arm64, never a platform manifest, so Docker picks the host's platform.
25
+ * Its image contract is `noSqlDbExpected*` in `classes.servicemanager.ts`.
24
26
  */
25
27
  export const noSqlDbImage =
26
- 'code.foss.global/lossless.zone/database@sha256:8fed3bc2da051a6ce29906383ea37e3ae777e2a7373869effbd3093fc4a2a650';
28
+ 'code.foss.global/lossless.zone/database@sha256:e5a3d3243c7b43fe42607210656b49a0296f84015ba26616fca2b0b3ff4dd2e0';
27
29
 
28
30
  /** The only image older GitZone releases ever ran the `mongodb` service with. */
29
31
  export const legacyMongoImage = 'mongo:7.0';
@@ -54,9 +56,10 @@ export const serviceDataDirectoryNames: { [key in TServiceName]: string } = {
54
56
  };
55
57
 
56
58
  /**
57
- * Image used to run each service, and therefore the image available to perform
58
- * a root-helper cleanup of that service's data directory: if the data exists,
59
- * the service ran, so its image is present locally.
59
+ * Image used to run each service, and the image that performs a root-helper
60
+ * cleanup of that service's data directory. The cleanup pulls it when it is
61
+ * missing locally, since the data may have been written by a container that
62
+ * ran another version of the image.
60
63
  */
61
64
  export const serviceImages: { [key in TServiceName]: string } = {
62
65
  mongodb: noSqlDbImage,
@@ -125,14 +125,15 @@ export const noSqlDbWirePort = '27017';
125
125
  /** Management UI port inside the container; deliberately never published. */
126
126
  export const noSqlDbUiPort = '3000';
127
127
  /*
128
- * Contract of the pinned `noSqlDbImage` (lossless.zone/database 2.0.0), as
128
+ * Contract of the pinned `noSqlDbImage` (lossless.zone/database 4.0.0), as
129
129
  * reported by its image config. A created container must carry exactly these
130
130
  * values; any drift means the container was not created by this release.
131
131
  */
132
132
  /** Numeric `uid:gid` of the image's `database` user; also owns the bind-mounted data. */
133
133
  export const noSqlDbContainerUser = '999:999';
134
134
  export const noSqlDbExpectedEntrypoint = ['/sbin/tini', '--'];
135
- export const noSqlDbExpectedCommand = ['deno', 'run', '--allow-all', 'mod.ts', 'server'];
135
+ /** The image's own `Cmd`; the container is created without a command of its own. */
136
+ export const noSqlDbExpectedCommand = ['node', 'cli.js', 'server'];
136
137
  /** The image's own HEALTHCHECK, compared exactly. */
137
138
  export const noSqlDbExpectedHealthcheck = {
138
139
  test: ['CMD-SHELL', 'wget -q -O /dev/null http://127.0.0.1:3000/readyz || exit 1'],
@@ -1282,6 +1283,10 @@ export class ServiceManager {
1282
1283
  private async reconcileNoSqlDbContainer(): Promise<{ id: string; outcome: string }> {
1283
1284
  const containers = this.config.getContainerNames();
1284
1285
  const directories = this.config.getDataDirectories();
1286
+ // The first start after a pin change has to pull the image. The pull has
1287
+ // its own bound; inside the deadline, the data helper or `docker create`
1288
+ // would pull it on demand and spend the readiness window on the download.
1289
+ await this.docker.ensureImagePresent(noSqlDbImage);
1285
1290
  const deadlineAt = this.noSqlDbClock.now() + noSqlDbReconciliationTimeoutMs;
1286
1291
  const dockerTimeout = (): { timeoutMs: number } => {
1287
1292
  const remaining = Math.floor(deadlineAt - this.noSqlDbClock.now());