UNPKG

@atomist/sdm-pack-node

Version:

Extension pack for an Atomist SDM to work with Node.js projects

64 lines 2.8 kB
"use strict"; /* * Copyright © 2019 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. */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const automation_client_1 = require("@atomist/automation-client"); const findAuthorName_1 = require("./findAuthorName"); /** * Code transform to update identification fields of package.json and package-lock.json * @param project * @param context * @param params */ exports.UpdatePackageJsonIdentification = (project, context, params) => __awaiter(this, void 0, void 0, function* () { const author = yield findAuthorName_1.findAuthorName(context.context, params.screenName) .then((authorName) => authorName || params.screenName, (err) => { automation_client_1.logger.warn("Cannot query for author name: %s", err.message); return params.screenName; }); const p = yield automation_client_1.doWithJson(project, "package.json", pkg => { const repoUrl = params.target.repoRef.url; pkg.name = params.appName; pkg.description = params.target.description; pkg.version = params.version; pkg.author = { name: author, }; pkg.repository = { type: "git", url: `${repoUrl}.git`, }; pkg.homepage = `${repoUrl}#readme`; pkg.bugs = { url: `${repoUrl}/issues`, }; }); if (yield p.hasFile("package-lock.json")) { yield automation_client_1.doWithJson(p, "package-lock.json", pkg => { pkg.name = params.appName; pkg.version = params.version; }); } }); //# sourceMappingURL=updatePackageJsonIdentification.js.map