Skip to content

Commit 0539cce

Browse files
willdurandRob--W
andauthored
feat: remove --id flag on web-ext sign (#3126)
Co-authored-by: Rob Wu <[email protected]>
1 parent 9fa3bf1 commit 0539cce

File tree

3 files changed

+14
-115
lines changed

3 files changed

+14
-115
lines changed

src/cmd/sign.js

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export default function sign(
2525
apiProxy,
2626
apiSecret,
2727
artifactsDir,
28-
id,
2928
ignoreFiles = [],
3029
sourceDir,
3130
timeout,
@@ -63,42 +62,25 @@ export default function sign(
6362
getIdFromFile(savedIdPath),
6463
]);
6564

66-
const manifestId = getManifestId(manifestData);
67-
68-
if (id && !manifestId) {
69-
throw new UsageError(
70-
`Cannot set custom ID ${id} - The add-on ID must be specified in the manifest.json file.`,
71-
);
72-
}
73-
if (idFromSourceDir && !manifestId) {
65+
const id = getManifestId(manifestData);
66+
if (idFromSourceDir && !id) {
7467
throw new UsageError(
7568
'Cannot use previously auto-generated extension ID ' +
76-
`${idFromSourceDir} - This add-on ID must be specified in the manifest.json file.`,
77-
);
78-
}
79-
if (id && manifestId) {
80-
throw new UsageError(
81-
`Cannot set custom ID ${id} because manifest.json ` +
82-
`already defines ID ${manifestId}`,
69+
`${idFromSourceDir} - This extension ID must be specified in the manifest.json file.`,
8370
);
8471
}
85-
if (id) {
86-
log.info(`Using custom ID declared as --id=${id}`);
87-
}
8872

89-
if (manifestId) {
90-
id = manifestId;
91-
}
73+
if (!id) {
74+
// We only auto-generate add-on IDs for MV2 add-ons on AMO.
75+
if (manifestData.manifest_version !== 2) {
76+
throw new UsageError(
77+
'An extension ID must be specified in the manifest.json file.',
78+
);
79+
}
9280

93-
if (!id && idFromSourceDir) {
94-
log.info(
95-
`Using previously auto-generated extension ID: ${idFromSourceDir}`,
81+
log.warn(
82+
'No extension ID specified (it will be auto-generated the first time)',
9683
);
97-
id = idFromSourceDir;
98-
}
99-
100-
if (!id) {
101-
log.warn('No extension ID specified (it will be auto-generated)');
10284
}
10385

10486
if (!channel) {

src/program.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -542,13 +542,6 @@ Example: $0 --help run.
542542
demandOption: false,
543543
type: 'string',
544544
},
545-
id: {
546-
describe:
547-
'A custom ID for the extension. This has no effect if the ' +
548-
'extension already declares an explicit ID in its manifest.',
549-
demandOption: false,
550-
type: 'string',
551-
},
552545
timeout: {
553546
describe: 'Number of milliseconds to wait before giving up',
554547
type: 'number',

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

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import completeSignCommand, {
1515
extensionIdFile,
1616
getIdFromFile,
1717
} from '../../../src/cmd/sign.js';
18-
import { basicManifest, manifestWithoutApps, fixturePath } from '../helpers.js';
18+
import { basicManifest, fixturePath } from '../helpers.js';
1919

2020
describe('sign', () => {
2121
function getStubs() {
@@ -115,82 +115,6 @@ describe('sign', () => {
115115
},
116116
));
117117

118-
it("doesn't allow a custom ID when no ID in manifest.json with submission api", () =>
119-
withTempDir(async (tmpDir) => {
120-
const customId = 'some-custom-id';
121-
const stubs = getStubs();
122-
const promiseSigned = sign(tmpDir, stubs, {
123-
extraArgs: {
124-
id: customId,
125-
},
126-
extraOptions: {
127-
preValidatedManifest: manifestWithoutApps,
128-
},
129-
});
130-
await assert.isRejected(promiseSigned, UsageError);
131-
await assert.isRejected(
132-
promiseSigned,
133-
/Cannot set custom ID some-custom-id/,
134-
);
135-
await assert.isRejected(
136-
promiseSigned,
137-
/The add-on ID must be specified in the manifest.json file/,
138-
);
139-
}));
140-
141-
it("doesn't allow ID file when no ID in manifest.json with submission api", () =>
142-
withTempDir(async (tmpDir) => {
143-
const sourceDir = path.join(tmpDir.path(), 'source-dir');
144-
const idFile = path.join(sourceDir, extensionIdFile);
145-
const stubs = getStubs();
146-
await fs.mkdir(sourceDir);
147-
await saveIdToFile(idFile, 'some-other-id');
148-
// Now, make a signing call with a custom ID.
149-
const promiseSigned = sign(tmpDir, stubs, {
150-
extraArgs: {
151-
sourceDir,
152-
},
153-
extraOptions: {
154-
preValidatedManifest: manifestWithoutApps,
155-
},
156-
});
157-
158-
await assert.isRejected(promiseSigned, UsageError);
159-
await assert.isRejected(
160-
promiseSigned,
161-
/Cannot use previously auto-generated extension ID/,
162-
);
163-
await assert.isRejected(promiseSigned, /some-other-id - /);
164-
await assert.isRejected(
165-
promiseSigned,
166-
/This add-on ID must be specified in the manifest.json file/,
167-
);
168-
}));
169-
170-
it('disallows a custom ID when manifest.json has ID', () =>
171-
withTempDir(async (tmpDir) => {
172-
const customId = 'some-custom-id';
173-
const stubs = getStubs();
174-
const signPromise = sign(tmpDir, stubs, {
175-
extraArgs: {
176-
id: customId,
177-
},
178-
extraOptions: {
179-
// This manifest has an ID in it.
180-
preValidatedManifest: basicManifest,
181-
},
182-
});
183-
await assert.isRejected(signPromise, UsageError);
184-
await assert.isRejected(
185-
signPromise,
186-
/Cannot set custom ID some-custom-id/,
187-
);
188-
await assert.isRejected(
189-
signPromise,
190-
/manifest\.json already defines ID basic-manifest@web-ext-test-suite/,
191-
);
192-
}));
193-
194118
it('requires a channel for submission API', () =>
195119
withTempDir(async (tmpDir) => {
196120
const stubs = getStubs();
@@ -199,7 +123,7 @@ describe('sign', () => {
199123
channel: '',
200124
},
201125
extraOptions: {
202-
preValidatedManifest: manifestWithoutApps,
126+
preValidatedManifest: basicManifest,
203127
},
204128
});
205129
await assert.isRejected(signPromise, UsageError);

0 commit comments

Comments
 (0)