Skip to content

Commit d4dbc99

Browse files
committed
feat(sign): add cli option to be specified when uploading without source code on purpose
1 parent b2cf0d5 commit d4dbc99

File tree

4 files changed

+61
-9
lines changed

4 files changed

+61
-9
lines changed

Diff for: src/cmd/sign.js

+15
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default function sign(
3333
channel,
3434
amoMetadata,
3535
uploadSourceCode,
36+
onlyHumanReadableSourceCode,
3637
webextVersion,
3738
},
3839
{
@@ -43,6 +44,20 @@ export default function sign(
4344
} = {},
4445
) {
4546
return withTempDir(async function (tmpDir) {
47+
if (!uploadSourceCode && !onlyHumanReadableSourceCode) {
48+
throw new UsageError(
49+
'Incomplete command. Either --upload-source-code or --only-human-readable-source-code ' +
50+
'CLI options should be explicitly included in the sign command.'
51+
);
52+
}
53+
54+
if (uploadSourceCode && onlyHumanReadableSourceCode) {
55+
throw new UsageError(
56+
'Invalid options. Only one of --upload-source-code or --only-human-readable-source-code ' +
57+
'CLI options should be included in the sign command.'
58+
);
59+
}
60+
4661
await prepareArtifactsDir(artifactsDir);
4762

4863
let manifestData;

Diff for: src/program.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -582,10 +582,22 @@ Example: $0 --help run.
582582
describe:
583583
'Path to an archive file containing human readable source code of this submission, ' +
584584
'if the code in --source-dir has been processed to make it unreadable. ' +
585+
'Use --only-human-readable-source-code option if source code assets ' +
586+
'in the submission are all human readable.' +
585587
'See https://extensionworkshop.com/documentation/publish/source-code-submission/ for ' +
586-
'details. Only used with `use-submission-api`',
588+
'details.',
587589
type: 'string',
588590
},
591+
'only-human-readable-source-code': {
592+
describe:
593+
'Signal that all source code assets in the xpi file are already human readable ' +
594+
'and uploading a separate source code archive is not necessary.' +
595+
'See https://extensionworkshop.com/documentation/publish/source-code-submission/ for ' +
596+
'details.',
597+
type: 'boolean',
598+
demandOption: false,
599+
default: null,
600+
},
589601
},
590602
)
591603
.command('run', 'Run the extension', commands.run, {

Diff for: tests/functional/test.cli.sign.js

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe('web-ext sign', () => {
6060
'--verbose',
6161
'--channel',
6262
'listed',
63+
'--only-human-readable-source-code',
6364
'--amo-base-url',
6465
'http://localhost:8989/fake/api/v5',
6566
'--api-key',
@@ -97,6 +98,7 @@ describe('web-ext sign', () => {
9798
sign: {
9899
amoBaseUrl: 'http://localhost:8989/fake/api/v5',
99100
channel: 'listed',
101+
onlyHumanReadableSourceCode: true,
100102
},
101103
sourceDir: srcDir,
102104
},

Diff for: tests/unit/test-cmd/test.sign.js

+31-8
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,22 @@ describe('sign', () => {
5757
* Run the sign command with stubs for all dependencies.
5858
*/
5959
function sign(tmpDir, stubs, { extraArgs = {}, extraOptions = {} } = {}) {
60+
const signCLIOptions = {
61+
verbose: false,
62+
artifactsDir: path.join(tmpDir.path(), 'artifacts-dir'),
63+
sourceDir: tmpDir.path(),
64+
channel: 'listed',
65+
...stubs.signingConfig,
66+
...extraArgs,
67+
};
68+
if (
69+
!('uploadSourceCode' in signCLIOptions) &&
70+
!('onlyHumanReadableSourceCode' in signCLIOptions)
71+
) {
72+
signCLIOptions.onlyHumanReadableSourceCode = true;
73+
}
6074
return completeSignCommand(
61-
{
62-
verbose: false,
63-
artifactsDir: path.join(tmpDir.path(), 'artifacts-dir'),
64-
sourceDir: tmpDir.path(),
65-
channel: 'listed',
66-
...stubs.signingConfig,
67-
...extraArgs,
68-
},
75+
signCLIOptions,
6976
{
7077
...stubs.signingOptions,
7178
...extraOptions,
@@ -89,6 +96,7 @@ describe('sign', () => {
8996
sourceDir,
9097
artifactsDir: path.join(tmpDir.path(), 'artifacts'),
9198
channel: 'listed',
99+
onlyHumanReadableSourceCode: true,
92100
...stubs.signingConfig,
93101
apiProxy,
94102
},
@@ -223,6 +231,21 @@ describe('sign', () => {
223231
});
224232
}));
225233

234+
it('rejects an UsageError if --upload-source-code or --only-human-readable-source-code are both falsey', async () => {
235+
const signPromise = completeSignCommand({});
236+
await assert.isRejected(signPromise, UsageError);
237+
await assert.isRejected(signPromise, /Incomplete command. Either .* CLI options should be explicitly included/);
238+
});
239+
240+
it('rejects an UsageError if --upload-source-code and --only-human-readable-source-code are both truthy', async () => {
241+
const signPromise = completeSignCommand({
242+
uploadSourceCode: 'fake-source-code-path.zip',
243+
onlyHumanReadableSourceCode: true,
244+
});
245+
await assert.isRejected(signPromise, UsageError);
246+
await assert.isRejected(signPromise, /Invalid options. Only one of .* CLI options should be included/);
247+
});
248+
226249
it('passes the uploadSourceCode parameter to submissionAPI signer as submissionSource', () =>
227250
withTempDir((tmpDir) => {
228251
const stubs = getStubs();

0 commit comments

Comments
 (0)