heroku-cli-buildpacks
Advanced tools
Comparing version 0.0.12-beta.1 to 0.0.12-beta.2
@@ -22,4 +22,5 @@ import { BuildpackRegistryApi as Api, Headers } from './buildpack-registry-api'; | ||
info(buildpack: string): Promise<InfoData>; | ||
revisionInfo(buildpack: string, revision_id: string): Promise<any>; | ||
buildpackExists(buildpack: string): Promise<any>; | ||
listVersions(buildpack: string): Promise<any>; | ||
} |
@@ -84,2 +84,5 @@ "use strict"; | ||
} | ||
async revisionInfo(buildpack, revision_id) { | ||
return this.api.get(`/buildpacks/${encodeURIComponent(buildpack)}/revisions/${encodeURIComponent(revision_id)}`); | ||
} | ||
async buildpackExists(buildpack) { | ||
@@ -86,0 +89,0 @@ return this.api.get(`/buildpacks/${encodeURIComponent(buildpack)}`); |
import { Command } from '@heroku-cli/command'; | ||
import { BuildpackRegistry } from '../../buildpack-registry'; | ||
export default class Publish extends Command { | ||
@@ -9,3 +10,5 @@ static description: string; | ||
}[]; | ||
delay(ms: number): Promise<{}>; | ||
waitForRelease(registry: BuildpackRegistry, buildpack_id: string, revision_id: string): Promise<string>; | ||
run(): Promise<void>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const command_1 = require("@heroku-cli/command"); | ||
const cli_ux_1 = require("cli-ux"); | ||
const cli = require('heroku-cli-util'); | ||
const buildpack_registry_1 = require("../../buildpack-registry"); | ||
class Publish extends command_1.Command { | ||
async delay(ms) { | ||
// Disable lint is Temporary | ||
// until this issue is resolved https://github.com/Microsoft/tslint-microsoft-contrib/issues/355#issuecomment-407209401 | ||
// tslint:disable-next-line no-string-based-set-timeout | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
} | ||
async waitForRelease(registry, buildpack_id, revision_id) { | ||
let status = ''; | ||
let status_count = 0; | ||
let running = true; | ||
while (running) { | ||
status_count += 1; | ||
let revision_response = await registry.revisionInfo(buildpack_id, revision_id); | ||
let revision_body = await revision_response.json(); | ||
status = revision_body.status; | ||
if (status !== 'pending') { | ||
break; | ||
} | ||
if (status_count === 60) { | ||
break; | ||
} | ||
await this.delay(2000); | ||
} | ||
if (status === 'failed') { | ||
return 'Failed to publish buildpack'; | ||
} | ||
else if (status === 'published') { | ||
return 'Publishing buildpack was successful'; | ||
} | ||
else if (status === 'pending') { | ||
return 'Process timed out buildpack revision is still pending'; | ||
} | ||
else { | ||
return `Publishing buildpack ended with status: ${status}`; | ||
} | ||
} | ||
async run() { | ||
@@ -17,6 +53,6 @@ let { args } = this.parse(Publish); | ||
if (!buildpackValidity.result) { | ||
cli_ux_1.cli.error(`Could not publish the buildpack.\n${buildpackValidity.error}`); | ||
cli.error(`Could not publish the buildpack.\n${buildpackValidity.error}`); | ||
} | ||
if (await registry.requiresTwoFactor(args.buildpack)) { | ||
let secondFactor = await cli_ux_1.cli.prompt('Two-factor code', { type: 'mask' }); | ||
let secondFactor = await cli.prompt('Two-factor code', { type: 'mask' }); | ||
await registry.publish(args.buildpack, args.tag_or_branch, herokuAuth, secondFactor); | ||
@@ -28,6 +64,12 @@ } | ||
if (response.status !== 200) { | ||
cli_ux_1.cli.error(`Could not publish ${args.buildpack}: ${body.error}`); | ||
cli.error(`Could not publish ${args.buildpack}: ${body.error}`); | ||
} | ||
else { | ||
let buildpack_id = body.buildpack_id; | ||
let revision_id = body.id; | ||
let task = this.waitForRelease(registry, buildpack_id, revision_id); | ||
let status = await cli.action(`Publishing buildpack ${args.buildpack}`, task); | ||
cli.log(`${status}`); | ||
} | ||
} | ||
cli_ux_1.cli.log(`Successfully published buildpack ${args.buildpack}.`); | ||
} | ||
@@ -34,0 +76,0 @@ } |
@@ -1,1 +0,1 @@ | ||
{"version":"0.0.12-beta.1","commands":{"buildpacks:add":{"id":"buildpacks:add","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{"app":{"name":"app","type":"option","char":"a","description":"app to run command against","required":true},"remote":{"name":"remote","type":"option","char":"r","description":"git remote of app to use"},"index":{"name":"index","type":"option","char":"i","description":"the 1-based index of the URL in the list of URLs"}},"args":[{"name":"buildpack","required":true}]},"buildpacks:clear":{"id":"buildpacks:clear","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{"app":{"name":"app","type":"option","char":"a","description":"app to run command against","required":true}},"args":[]},"buildpacks":{"id":"buildpacks","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{"app":{"name":"app","type":"option","char":"a","description":"app to run command against","required":true}},"args":[]},"buildpacks:info":{"id":"buildpacks:info","description":"fetch info about a buildpack","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"buildpack","description":"namespace/name of the buildpack"}]},"buildpacks:init":{"id":"buildpacks:init","description":"bootstrap a new buildpack","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"name","description":"name of the buildpack","required":true}]},"buildpacks:publish":{"id":"buildpacks:publish","description":"publish new revision of buildpack","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"buildpack","description":"namespace/name of the buildpack"},{"name":"tag_or_branch","description":"a tag or branch for publishing"}]},"buildpacks:register":{"id":"buildpacks:register","description":"create a buildpack","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{},"args":[]},"buildpacks:remove":{"id":"buildpacks:remove","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{"app":{"name":"app","type":"option","char":"a","description":"app to run command against","required":true},"remote":{"name":"remote","type":"option","char":"r","description":"git remote of app to use"},"index":{"name":"index","type":"option","char":"i","description":"the 1-based index of the URL to remove from the list of URLs"}},"args":[{"name":"buildpack"}]},"buildpacks:rollback":{"id":"buildpacks:rollback","description":"rollback to a previous revision of the buildpack","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"buildpack","description":"namespace/name of the buildpack"}]},"buildpacks:search":{"id":"buildpacks:search","description":"search for buildpacks","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{"namespace":{"name":"namespace","type":"option","description":"buildpack namespaces to filter on using a comma separated list"},"name":{"name":"name","type":"option","description":"buildpack names to filter on using a comma separated list "},"description":{"name":"description","type":"option","description":"buildpack description to filter on"}},"args":[]},"buildpacks:set":{"id":"buildpacks:set","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{"app":{"name":"app","type":"option","char":"a","description":"app to run command against","required":true},"remote":{"name":"remote","type":"option","char":"r","description":"git remote of app to use"},"index":{"name":"index","type":"option","char":"i","description":"the 1-based index of the URL in the list of URLs"}},"args":[{"name":"buildpack","required":true}]},"buildpacks:versions":{"id":"buildpacks:versions","description":"list versions of a buildpack","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"buildpack","description":"namespace/name of the buildpack"}]}}} | ||
{"version":"0.0.12-beta.2","commands":{"buildpacks:add":{"id":"buildpacks:add","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{"app":{"name":"app","type":"option","char":"a","description":"app to run command against","required":true},"remote":{"name":"remote","type":"option","char":"r","description":"git remote of app to use"},"index":{"name":"index","type":"option","char":"i","description":"the 1-based index of the URL in the list of URLs"}},"args":[{"name":"buildpack","required":true}]},"buildpacks:clear":{"id":"buildpacks:clear","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{"app":{"name":"app","type":"option","char":"a","description":"app to run command against","required":true}},"args":[]},"buildpacks":{"id":"buildpacks","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{"app":{"name":"app","type":"option","char":"a","description":"app to run command against","required":true}},"args":[]},"buildpacks:info":{"id":"buildpacks:info","description":"fetch info about a buildpack","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"buildpack","description":"namespace/name of the buildpack"}]},"buildpacks:init":{"id":"buildpacks:init","description":"bootstrap a new buildpack","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"name","description":"name of the buildpack","required":true}]},"buildpacks:publish":{"id":"buildpacks:publish","description":"publish new revision of buildpack","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"buildpack","description":"namespace/name of the buildpack"},{"name":"tag_or_branch","description":"a tag or branch for publishing"}]},"buildpacks:register":{"id":"buildpacks:register","description":"create a buildpack","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{},"args":[]},"buildpacks:remove":{"id":"buildpacks:remove","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{"app":{"name":"app","type":"option","char":"a","description":"app to run command against","required":true},"remote":{"name":"remote","type":"option","char":"r","description":"git remote of app to use"},"index":{"name":"index","type":"option","char":"i","description":"the 1-based index of the URL to remove from the list of URLs"}},"args":[{"name":"buildpack"}]},"buildpacks:rollback":{"id":"buildpacks:rollback","description":"rollback to a previous revision of the buildpack","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"buildpack","description":"namespace/name of the buildpack"}]},"buildpacks:search":{"id":"buildpacks:search","description":"search for buildpacks","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{"namespace":{"name":"namespace","type":"option","description":"buildpack namespaces to filter on using a comma separated list"},"name":{"name":"name","type":"option","description":"buildpack names to filter on using a comma separated list "},"description":{"name":"description","type":"option","description":"buildpack description to filter on"}},"args":[]},"buildpacks:set":{"id":"buildpacks:set","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{"app":{"name":"app","type":"option","char":"a","description":"app to run command against","required":true},"remote":{"name":"remote","type":"option","char":"r","description":"git remote of app to use"},"index":{"name":"index","type":"option","char":"i","description":"the 1-based index of the URL in the list of URLs"}},"args":[{"name":"buildpack","required":true}]},"buildpacks:versions":{"id":"buildpacks:versions","description":"list versions of a buildpack","pluginName":"heroku-cli-buildpacks","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"buildpack","description":"namespace/name of the buildpack"}]}}} |
{ | ||
"name": "heroku-cli-buildpacks", | ||
"version": "0.0.12-beta.1", | ||
"version": "0.0.12-beta.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -11,2 +11,17 @@ # Buildpack Registry Plugin | ||
## Local dev | ||
First uninstall existing plugin: | ||
```term | ||
$ heroku plugins:uninstall heroku-cli-buildpacks | ||
``` | ||
Then link the local directory: | ||
```term | ||
$ heroku plugins:link | ||
heroku: linking plugin heroku-cli-buildpacks... done | ||
``` | ||
## Usage | ||
@@ -13,0 +28,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
50070
1093
67
3