Skip to content

Commit ec67942

Browse files
committed
version-source to upload-source-code; reword helptext;
versionSource in submit-addon.js to submissionSource; versionPatchData to patchData.version
1 parent df6d215 commit ec67942

File tree

5 files changed

+46
-41
lines changed

5 files changed

+46
-41
lines changed

src/cmd/sign.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default function sign(
4040
verbose,
4141
channel,
4242
amoMetadata,
43-
versionSource,
43+
uploadSourceCode,
4444
webextVersion,
4545
},
4646
{
@@ -153,7 +153,7 @@ export default function sign(
153153
validationCheckTimeout: timeout,
154154
approvalCheckTimeout:
155155
approvalTimeout !== undefined ? approvalTimeout : timeout,
156-
versionSource,
156+
submissionSource: uploadSourceCode,
157157
});
158158
} else {
159159
const {

src/program.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,13 @@ Example: $0 --help run.
601601
'Only used with `use-submission-api`',
602602
type: 'string',
603603
},
604-
'version-source': {
604+
'upload-source-code': {
605605
describe:
606-
'Path to a zip file containing human readable source code for a version. ' +
607-
'Only used with `use-submission-api`',
606+
'Path to an archive file containing human readable source code of this submission, ' +
607+
'if the code in --source-dir has been processed to make it unreadable. ' +
608+
'See https://extensionworkshop.com/documentation/publish/source-code-submission/ for ' +
609+
'details. Only used with `use-submission-api`',
610+
type: 'string',
608611
},
609612
},
610613
)

src/util/submit-addon.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,17 @@ export default class Client {
371371
uploadUuid,
372372
savedIdPath,
373373
metaDataJson,
374-
versionPatchData,
374+
patchData,
375375
saveIdToFileFunc = saveIdToFile,
376376
) {
377377
const {
378378
guid: addonId,
379379
version: { id: newVersionId, edit_url: editUrl },
380380
} = await this.doNewAddonSubmit(uploadUuid, metaDataJson);
381381

382-
if (versionPatchData) {
382+
if (patchData && patchData.version) {
383383
log.info('Submitting source zip');
384-
await this.doFormDataPatch(versionPatchData, addonId, newVersionId);
384+
await this.doFormDataPatch(patchData.version, addonId, newVersionId);
385385
}
386386

387387
await saveIdToFileFunc(savedIdPath, addonId);
@@ -392,14 +392,14 @@ export default class Client {
392392
return this.doAfterSubmit(addonId, newVersionId, editUrl);
393393
}
394394

395-
async putVersion(uploadUuid, addonId, metaDataJson, versionPatchData) {
395+
async putVersion(uploadUuid, addonId, metaDataJson, patchData) {
396396
const {
397397
version: { id: newVersionId, edit_url: editUrl },
398398
} = await this.doNewAddonOrVersionSubmit(addonId, uploadUuid, metaDataJson);
399399

400-
if (versionPatchData) {
400+
if (patchData && patchData.version) {
401401
log.info('Submitting source zip');
402-
await this.doFormDataPatch(versionPatchData, addonId, newVersionId);
402+
await this.doFormDataPatch(patchData.version, addonId, newVersionId);
403403
}
404404
return this.doAfterSubmit(addonId, newVersionId, editUrl);
405405
}
@@ -419,7 +419,7 @@ export async function signAddon({
419419
savedIdPath,
420420
savedUploadUuidPath,
421421
metaDataJson = {},
422-
versionSource,
422+
submissionSource,
423423
userAgentString,
424424
SubmitClient = Client,
425425
ApiAuthClass = JwtApiAuth,
@@ -456,9 +456,11 @@ export async function signAddon({
456456
savedUploadUuidPath,
457457
);
458458
// if we have a source file we need to upload we patch after the create
459-
const versionPatchData = versionSource
460-
? { source: client.fileFromSync(versionSource) }
461-
: undefined;
459+
const patchData = {
460+
version: submissionSource
461+
? { source: client.fileFromSync(submissionSource) }
462+
: undefined,
463+
};
462464

463465
// We specifically need to know if `id` has not been passed as a parameter because
464466
// it's the indication that a new add-on should be created, rather than a new version.
@@ -467,11 +469,11 @@ export async function signAddon({
467469
uploadUuid,
468470
savedIdPath,
469471
metaDataJson,
470-
versionPatchData,
472+
patchData,
471473
);
472474
}
473475

474-
return client.putVersion(uploadUuid, id, metaDataJson, versionPatchData);
476+
return client.putVersion(uploadUuid, id, metaDataJson, patchData);
475477
}
476478

477479
export async function saveIdToFile(filePath, id) {

tests/unit/test-cmd/test.sign.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,20 +384,20 @@ describe('sign', () => {
384384
});
385385
}));
386386

387-
it('passes the versionSource parameter to submissionAPI signer', () =>
387+
it('passes the uploadSourceCode parameter to submissionAPI signer as submissionSource', () =>
388388
withTempDir((tmpDir) => {
389389
const stubs = getStubs();
390-
const versionSource = 'path/to/source.zip';
390+
const uploadSourceCode = 'path/to/source.zip';
391391
return sign(tmpDir, stubs, {
392392
extraArgs: {
393-
versionSource,
393+
uploadSourceCode,
394394
useSubmissionApi: true,
395395
channel: 'unlisted',
396396
},
397397
}).then(() => {
398398
sinon.assert.called(stubs.signingOptions.submitAddon);
399399
sinon.assert.calledWithMatch(stubs.signingOptions.submitAddon, {
400-
versionSource,
400+
submissionSource: uploadSourceCode,
401401
});
402402
});
403403
}));

tests/unit/test-util/test.submit-addon.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -195,39 +195,39 @@ describe('util.submit-addon', () => {
195195
);
196196
});
197197

198-
it('includes source data to be patched if versionSource defined for new addon', async () => {
199-
const versionSource = 'path/to/source/zip';
198+
it('includes source data to be patched if submissionSource defined for new addon', async () => {
199+
const submissionSource = 'path/to/source/zip';
200200
await signAddon({
201201
...signAddonDefaults,
202-
versionSource,
202+
submissionSource,
203203
});
204204

205-
sinon.assert.calledWith(fileFromSyncStub, versionSource);
205+
sinon.assert.calledWith(fileFromSyncStub, submissionSource);
206206
sinon.assert.calledWith(
207207
postNewAddonStub,
208208
uploadUuid,
209209
signAddonDefaults.savedIdPath,
210210
{},
211-
{ source: fakeFileFromSync },
211+
{ version: { source: fakeFileFromSync } },
212212
);
213213
});
214214

215-
it('includes source data to be patched if versionSource defined for new version', async () => {
216-
const versionSource = 'path/to/source/zip';
215+
it('includes source data to be patched if submissionSource defined for new version', async () => {
216+
const submissionSource = 'path/to/source/zip';
217217
const id = '@thisID';
218218
await signAddon({
219219
...signAddonDefaults,
220-
versionSource,
220+
submissionSource,
221221
id,
222222
});
223223

224-
sinon.assert.calledWith(fileFromSyncStub, versionSource);
224+
sinon.assert.calledWith(fileFromSyncStub, submissionSource);
225225
sinon.assert.calledWith(
226226
putVersionStub,
227227
uploadUuid,
228228
id,
229229
{},
230-
{ source: fakeFileFromSync },
230+
{ version: { source: fakeFileFromSync } },
231231
);
232232
});
233233
});
@@ -1006,7 +1006,7 @@ describe('util.submit-addon', () => {
10061006
});
10071007

10081008
describe('doFormDataPatch called correctly', () => {
1009-
const versionPatchData = { source: 'somesource' };
1009+
const patchData = { version: { source: 'somesource' } };
10101010
const metaDataJson = { some: 'metadata' };
10111011
const newVersionId = 123456;
10121012
const editUrl = 'http://some/url';
@@ -1034,57 +1034,57 @@ describe('util.submit-addon', () => {
10341034
doFormDataPatchStub.reset();
10351035
});
10361036

1037-
it('calls doFormDataPatch if versionPatchData is defined for postNewAddon', async () => {
1037+
it('calls doFormDataPatch if patchData.version is defined for postNewAddon', async () => {
10381038
const saveIdToFileStub = sinon.stub().resolves();
10391039
const savedIdPath = 'some/saved/id/path';
10401040
await stubbedClient.postNewAddon(
10411041
uploadUuid,
10421042
savedIdPath,
10431043
metaDataJson,
1044-
versionPatchData,
1044+
patchData,
10451045
saveIdToFileStub,
10461046
);
10471047

10481048
sinon.assert.calledWith(
10491049
doFormDataPatchStub,
1050-
versionPatchData,
1050+
patchData.version,
10511051
addonId,
10521052
newVersionId,
10531053
);
10541054
});
10551055

1056-
it('calls doFormDataPatch if versionPatchData is defined for putVersion', async () => {
1056+
it('calls doFormDataPatch if patchData.version is defined for putVersion', async () => {
10571057
await stubbedClient.putVersion(
10581058
uploadUuid,
10591059
addonId,
10601060
metaDataJson,
1061-
versionPatchData,
1061+
patchData,
10621062
);
10631063

10641064
sinon.assert.called(doFormDataPatchStub);
10651065
sinon.assert.calledWith(
10661066
doFormDataPatchStub,
1067-
versionPatchData,
1067+
patchData.version,
10681068
addonId,
10691069
newVersionId,
10701070
);
10711071
});
10721072

1073-
it('does not call doFormDataPatch is versionPatchData is undefined for postNewAddon', async () => {
1073+
it('does not call doFormDataPatch is patchData.version is undefined for postNewAddon', async () => {
10741074
const saveIdToFileStub = sinon.stub().resolves();
10751075
const savedIdPath = 'some/saved/id/path';
10761076
await stubbedClient.postNewAddon(
10771077
uploadUuid,
10781078
savedIdPath,
10791079
metaDataJson,
1080-
undefined,
1080+
{},
10811081
saveIdToFileStub,
10821082
);
10831083

10841084
sinon.assert.notCalled(doFormDataPatchStub);
10851085
});
10861086

1087-
it('does not call doFormDataPatch is versionPatchData is undefined for putVersion', async () => {
1087+
it('does not call doFormDataPatch is patchData.version is undefined for putVersion', async () => {
10881088
await stubbedClient.putVersion(uploadUuid, addonId, metaDataJson);
10891089

10901090
sinon.assert.notCalled(doFormDataPatchStub);

0 commit comments

Comments
 (0)