From 1db68ea4d6b9acb6b97c384b09e04454cd9e5598 Mon Sep 17 00:00:00 2001 From: Christian Dupuis Date: Wed, 3 Oct 2018 01:15:49 +0200 Subject: [PATCH] Add tags to ExtensionPack metadata (#543) fixes #542 --- lib/api-helper/misc/extensionPack.ts | 1 + lib/api/machine/ExtensionPack.ts | 14 +++++++++++ test/api-helper/misc/extensionPack.test.ts | 29 ++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 test/api-helper/misc/extensionPack.test.ts diff --git a/lib/api-helper/misc/extensionPack.ts b/lib/api-helper/misc/extensionPack.ts index a937badf9..cd94f8ec0 100644 --- a/lib/api-helper/misc/extensionPack.ts +++ b/lib/api-helper/misc/extensionPack.ts @@ -32,5 +32,6 @@ export function metadata(name?: string): ExtensionPackMetadata { name: name ? `${pj.name}:${name.toLocaleLowerCase()}` : pj.name, vendor: pj.author && pj.author.name ? pj.author.name : pj.author, version: pj.version ? pj.version : "", + tags: pj.keywords ? pj.keywords : [], }; } diff --git a/lib/api/machine/ExtensionPack.ts b/lib/api/machine/ExtensionPack.ts index 958c524a5..5477275d4 100644 --- a/lib/api/machine/ExtensionPack.ts +++ b/lib/api/machine/ExtensionPack.ts @@ -20,11 +20,25 @@ import { MachineConfigurer } from "./MachineConfigurer"; export interface ExtensionPackMetadata { + /** + * Name of the extension pack + */ name: string; + /** + * Vendor or author of this extension pack + */ vendor: string; + /** + * Version of extension pack + */ version: string; + + /** + * Optional tags of extension pack + */ + tags?: string | string[]; } /** diff --git a/test/api-helper/misc/extensionPack.test.ts b/test/api-helper/misc/extensionPack.test.ts new file mode 100644 index 000000000..566f22f02 --- /dev/null +++ b/test/api-helper/misc/extensionPack.test.ts @@ -0,0 +1,29 @@ +/* + * Copyright © 2018 Atomist, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as assert from "power-assert"; +import { metadata } from "../../../lib/api-helper/misc/extensionPack"; + +describe("extensionPack", () => { + + it("should correctly read metadata from package.json", () => { + const epm = metadata("test"); + assert.equal(epm.name, "@atomist/sdm:test"); + assert.equal(epm.vendor, "Atomist"); + assert.equal(epm.tags.length, 5); + }); + +});