@gjsify/cli 0.64.53 → 0.64.54

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.
@@ -203,6 +203,27 @@ export interface StorePublishInput {
203
203
  /** AMO only: a source archive attached to the version, for bundled or minified code. Absolute path. */
204
204
  readonly sourceZip?: string;
205
205
  }
206
+ /** Listing texts for a store whose API takes them (AMO only). Locales are the STORE's codes, already mapped. */
207
+ export interface StoreListingInput {
208
+ readonly description: Readonly<Record<string, string>>;
209
+ readonly privacyPolicy?: Readonly<Record<string, string>>;
210
+ /** Per version, no locales. `version` is a version id (digits) or a version number. */
211
+ readonly approvalNotes?: {
212
+ readonly version: string;
213
+ readonly text: string;
214
+ };
215
+ }
216
+ /** What one field held after the write, as READ back — `unread` when the read did not establish it. */
217
+ export interface StoreListingFieldResult {
218
+ readonly field: string;
219
+ readonly locale?: string;
220
+ readonly sent: number;
221
+ readonly verdict: 'match' | 'mismatch' | 'unread';
222
+ readonly detail: string;
223
+ }
224
+ export interface StoreListingResult {
225
+ readonly fields: readonly StoreListingFieldResult[];
226
+ }
206
227
  /**
207
228
  * What every store backend answers to. Three verbs, because that is what both
208
229
  * vendor APIs expose: push the package, ask for review, read what happened.
@@ -218,6 +239,8 @@ export interface StoreBackend {
218
239
  status(): Promise<StoreStatusResult>;
219
240
  /** Read an asynchronous operation once (Edge: the 202's `Location` id). Absent on a store whose uploads are not operations. */
220
241
  operation?(kind: StoreOperationKind, operationId: string, version?: string): Promise<StoreOperationResult>;
242
+ /** Write listing texts, then read each back. Absent on a store with no listing API (Chrome, Edge). */
243
+ updateListing?(input: StoreListingInput): Promise<StoreListingResult>;
221
244
  /** A read-only call that proves the credentials work, for `--dry-run`. Resolves when they do, throws otherwise. */
222
245
  verifyCredentials?(): Promise<void>;
223
246
  }
@@ -19,6 +19,10 @@ export interface SubmitCommandInput {
19
19
  readonly listingDir?: string;
20
20
  /** AMO only: a source archive for the reviewers, attached when a version is created (`--submit`). */
21
21
  readonly sourceZip?: string;
22
+ /** AMO only: send the listing texts from `listingDir` instead of the zip. */
23
+ readonly listingOnly?: boolean;
24
+ /** With `listingOnly`: the version (id or number) that gets the reviewer notes. */
25
+ readonly notesVersion?: string;
22
26
  readonly project: SubmitProject;
23
27
  readonly env: EnvLike;
24
28
  readonly createBackend?: (store: StoreId, env: EnvLike, options?: StoreBackendOptions) => StoreBackend;
@@ -39,5 +43,14 @@ export interface StoreJsonPreflight {
39
43
  }
40
44
  /** Checks a `store.json` text against what `StoreManifest` promises; pure so a spec needs no disk. */
41
45
  export declare function preflightStoreJson(text: string, listingStore: string, path: string): StoreJsonPreflight;
46
+ export interface ReviewerNotes {
47
+ readonly text: string;
48
+ readonly path: string;
49
+ }
50
+ /**
51
+ * The reviewer notes `webext listing` wrote for this store: `en` if it has the file, else the first
52
+ * language directory (sorted) that does. Undefined when there is none or it is empty.
53
+ */
54
+ export declare function findReviewerNotes(listingRoot: string, listingStore: string): ReviewerNotes | undefined;
42
55
  /** Runs the command and returns its exit code (`SUBMIT_EXIT_CODES` for a drive, 1 for any refusal). */
43
56
  export declare function runSubmit(input: SubmitCommandInput): Promise<number>;
@@ -11,9 +11,11 @@
11
11
  // `store.json` is a PREFLIGHT, never a payload (ADR 0135): neither store takes
12
12
  // listing text through its API, so nothing from it is sent. It only stops a
13
13
  // release whose listing the dashboard would refuse a day later.
14
- import { existsSync, readFileSync } from 'node:fs';
14
+ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
15
15
  import { join, resolve } from 'node:path';
16
+ import { runListingUpload } from './listing-upload.js';
16
17
  import { asStoreId, createStoreBackend, redactSecrets, STORE_CREDENTIALS, StoreUnsupportedError, STORES, } from './stores/index.js';
18
+ import { readText } from './stores/amo-listing.js';
17
19
  import { driveSubmission, SUBMIT_EXIT_CODES } from './stores/poll.js';
18
20
  /** `webext listing` names the Chrome store `cws`. */
19
21
  const LISTING_STORE = { chrome: 'cws', edge: 'edge', amo: 'amo' };
@@ -61,6 +63,26 @@ export function preflightStoreJson(text, listingStore, path) {
61
63
  }
62
64
  return { problems, manual };
63
65
  }
66
+ /**
67
+ * The reviewer notes `webext listing` wrote for this store: `en` if it has the file, else the first
68
+ * language directory (sorted) that does. Undefined when there is none or it is empty.
69
+ */
70
+ export function findReviewerNotes(listingRoot, listingStore) {
71
+ const storeDir = join(listingRoot, listingStore);
72
+ if (!existsSync(storeDir))
73
+ return undefined;
74
+ const languages = readdirSync(storeDir)
75
+ .filter((entry) => statSync(join(storeDir, entry)).isDirectory())
76
+ .sort();
77
+ for (const language of ['en', ...languages.filter((l) => l !== 'en')]) {
78
+ if (!languages.includes(language))
79
+ continue;
80
+ const text = readText(join(storeDir, language), 'reviewer-notes.txt');
81
+ if (text !== undefined && text !== '')
82
+ return { text, path: join(storeDir, language, 'reviewer-notes.txt') };
83
+ }
84
+ return undefined;
85
+ }
64
86
  function secretsOf(store, env) {
65
87
  return STORE_CREDENTIALS[store]
66
88
  .filter((field) => field.secret)
@@ -102,6 +124,30 @@ export async function runSubmit(input) {
102
124
  }
103
125
  timeoutMs = input.timeoutSeconds * 1000;
104
126
  }
127
+ if (input.listingOnly) {
128
+ if (store !== 'amo') {
129
+ throw new Error('gjsify webext submit: --listing-only applies to AMO only; Chrome and Edge have no listing API.');
130
+ }
131
+ if (input.submit || input.zip !== undefined || input.sourceZip !== undefined) {
132
+ throw new Error('gjsify webext submit: --listing-only sends texts only; drop --submit, --zip and --source.');
133
+ }
134
+ const log = env['GJSIFY_WEBEXT_DEBUG'] ? (msg) => err(msg) : undefined;
135
+ return await runListingUpload({
136
+ listingRoot: resolve(project.root, input.listingDir ?? 'dist/listing'),
137
+ dryRun: input.dryRun,
138
+ notesVersion: input.notesVersion,
139
+ backend: () => (input.createBackend ?? createStoreBackend)(store, env, {
140
+ fetchImpl: input.fetchImpl,
141
+ sleep: input.sleep,
142
+ now: input.now,
143
+ log,
144
+ }),
145
+ out,
146
+ });
147
+ }
148
+ if (input.notesVersion !== undefined) {
149
+ throw new Error('gjsify webext submit: --notes-version belongs to --listing-only.');
150
+ }
105
151
  const listingStore = LISTING_STORE[store];
106
152
  const storeJson = join(resolve(project.root, input.listingDir ?? 'dist/listing'), listingStore, 'store.json');
107
153
  if (!existsSync(storeJson)) {
@@ -128,22 +174,35 @@ export async function runSubmit(input) {
128
174
  if (!input.dryRun && !existsSync(zipPath)) {
129
175
  throw new Error(`gjsify webext submit: ${zipPath} does not exist. Run \`gjsify webext zip\` first or pass --zip.`);
130
176
  }
177
+ const notes = store === 'edge' || store === 'amo'
178
+ ? findReviewerNotes(resolve(project.root, input.listingDir ?? 'dist/listing'), listingStore)
179
+ : undefined;
180
+ if (notes === undefined && store === 'edge' && input.submit) {
181
+ err('warning: no reviewer-notes.txt under the listing dir; Edge reviewers expect certification notes. ' +
182
+ 'Run `gjsify webext listing --store edge` first. Continuing without notes.');
183
+ }
131
184
  const log = env['GJSIFY_WEBEXT_DEBUG'] ? (msg) => err(msg) : undefined;
132
185
  const options = { fetchImpl: input.fetchImpl, sleep: input.sleep, now: input.now, log };
133
186
  const backend = (input.createBackend ?? createStoreBackend)(store, env, options);
134
187
  if (input.dryRun) {
135
188
  if (backend.verifyCredentials === undefined) {
136
189
  out(`${descriptor.label}: dry run — credentials are set; this backend has no read-only check, so they are unverified. Nothing was uploaded.`);
190
+ if (input.submit && notes !== undefined) {
191
+ out(` would send reviewer notes from ${notes.path}: ${notes.text.length} chars`);
192
+ }
137
193
  return 0;
138
194
  }
139
195
  await backend.verifyCredentials();
140
196
  out(`${descriptor.label}: dry run — credentials accepted (one read). ${existsSync(zipPath) ? 'The zip exists' : `No zip at ${zipPath} yet`}. Nothing was uploaded.`);
197
+ if (input.submit && notes !== undefined) {
198
+ out(` would send reviewer notes from ${notes.path}: ${notes.text.length} chars`);
199
+ }
141
200
  return 0;
142
201
  }
143
202
  const result = await driveSubmission({
144
203
  backend,
145
204
  upload: { zipPath, version: project.version },
146
- publish: input.submit ? { version: project.version, sourceZip } : undefined,
205
+ publish: input.submit ? { version: project.version, sourceZip, notes: notes?.text } : undefined,
147
206
  }, { timeoutMs, sleep: input.sleep, now: input.now, log, secrets });
148
207
  const write = result.exitCode === 0 ? out : err;
149
208
  for (const line of describeResult(result, descriptor.label))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/cli",
3
- "version": "0.64.53",
3
+ "version": "0.64.54",
4
4
  "description": "CLI for Gjsify",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -142,22 +142,22 @@
142
142
  "cli"
143
143
  ],
144
144
  "dependencies": {
145
- "@gjsify/blueprint": "0.64.53",
146
- "@gjsify/buffer": "0.64.53",
147
- "@gjsify/create-app": "0.64.53",
148
- "@gjsify/node-globals": "0.64.53",
149
- "@gjsify/node-polyfills": "0.64.53",
150
- "@gjsify/npm-registry": "0.64.53",
151
- "@gjsify/resolve-npm": "0.64.53",
152
- "@gjsify/rolldown-plugin-gjsify": "0.64.53",
153
- "@gjsify/vite-plugin-blueprint": "0.64.53",
154
- "@gjsify/rolldown-plugin-pnp": "0.64.53",
155
- "@gjsify/semver": "0.64.53",
156
- "@gjsify/tar": "0.64.53",
157
- "@gjsify/tsc": "0.64.53",
158
- "@gjsify/utils": "0.64.53",
159
- "@gjsify/web-polyfills": "0.64.53",
160
- "@gjsify/workspace": "0.64.53",
145
+ "@gjsify/blueprint": "0.64.54",
146
+ "@gjsify/buffer": "0.64.54",
147
+ "@gjsify/create-app": "0.64.54",
148
+ "@gjsify/node-globals": "0.64.54",
149
+ "@gjsify/node-polyfills": "0.64.54",
150
+ "@gjsify/npm-registry": "0.64.54",
151
+ "@gjsify/resolve-npm": "0.64.54",
152
+ "@gjsify/rolldown-plugin-gjsify": "0.64.54",
153
+ "@gjsify/vite-plugin-blueprint": "0.64.54",
154
+ "@gjsify/rolldown-plugin-pnp": "0.64.54",
155
+ "@gjsify/semver": "0.64.54",
156
+ "@gjsify/tar": "0.64.54",
157
+ "@gjsify/tsc": "0.64.54",
158
+ "@gjsify/utils": "0.64.54",
159
+ "@gjsify/web-polyfills": "0.64.54",
160
+ "@gjsify/workspace": "0.64.54",
161
161
  "acorn": "^8.17.0",
162
162
  "cosmiconfig": "^9.0.2",
163
163
  "get-tsconfig": "^4.14.0",
@@ -166,13 +166,13 @@
166
166
  "yargs": "^18.0.0"
167
167
  },
168
168
  "devDependencies": {
169
- "@gjsify/unit": "0.64.53",
169
+ "@gjsify/unit": "0.64.54",
170
170
  "@types/yargs": "^17.0.35",
171
171
  "typescript": "^6.0.3"
172
172
  },
173
173
  "peerDependencies": {
174
- "@gjsify/oxfmt-native": "0.64.53",
175
- "@gjsify/rolldown-native": "0.64.53"
174
+ "@gjsify/oxfmt-native": "0.64.54",
175
+ "@gjsify/rolldown-native": "0.64.54"
176
176
  },
177
177
  "peerDependenciesMeta": {
178
178
  "@gjsify/oxfmt-native": {