check for enableProposedApi and don't allow to publish

This commit is contained in:
Johannes Rieken 2016-11-10 16:32:34 +01:00
parent dbcceabecb
commit 13a509aeeb
3 changed files with 19 additions and 3 deletions

View file

@ -22,6 +22,7 @@ export interface Manifest {
markdown?: 'github' | 'standard';
_bundling?: { [name: string]: string; }[];
_testing?: string;
enableProposedApi?: boolean;
// optional (npm)
author?: string | Person;
@ -53,4 +54,4 @@ export interface Manifest {
// cpu?: string[];
// preferGlobal
// publishConfig
}
}

View file

@ -432,6 +432,10 @@ export function validateManifest(manifest: Manifest): Manifest {
throw new Error('Manifest missing field: engines.vscode');
}
if (manifest.enableProposedApi) {
throw new Error('Extensions using proposed API (enableProposedApi: true) cannot be published');
}
return manifest;
}
@ -471,7 +475,7 @@ export function writeManifest(cwd: string, manifest: Manifest): Promise<void> {
}
export function toVsixManifest(assets: IAsset[], vsix: any, options: IPackageOptions = {}): Promise<string> {
return readFile(vsixManifestTemplatePath, 'utf8')
return readFile(vsixManifestTemplatePath, 'utf8')
.then(vsixManifestTemplateStr => _.template(vsixManifestTemplateStr))
.then(vsixManifestTemplate => vsixManifestTemplate(vsix));
}

View file

@ -147,6 +147,17 @@ describe('validateManifest', () => {
assert.throws(() => { validateManifest({ publisher: 'demo', name: 'demo', version: '1.0.0', engines: null }); });
assert.throws(() => { validateManifest({ publisher: 'demo', name: 'demo', version: '1.0.0', engines: { vscode: null } }); });
});
it('should not allow proposed API', () => {
assert.throws(() => { validateManifest({ enableProposedApi: true, publisher: 'demo', name: 'demo', version: '1.0.0', engines: { vscode: '0.10.1' } }); });
assert.throws(() => { validateManifest({ enableProposedApi: <any>1, publisher: 'demo', name: 'demo', version: '1.0.0', engines: { vscode: '0.10.1' } }); });
let mani1: Manifest = { enableProposedApi: false, publisher: 'demo', name: 'demo', version: '1.0.0', engines: { vscode: '0.10.1' } };
assert.ok(validateManifest(mani1) === mani1);
let mani2: Manifest = { publisher: 'demo', name: 'demo', version: '1.0.0', engines: { vscode: '0.10.1' } };
assert.ok(validateManifest(mani2) === mani2);
});
});
describe('toVsixManifest', () => {
@ -1181,4 +1192,4 @@ describe('MarkdownProcessor', () => {
});
});
});
});
});