@@ -2,6 +2,7 @@ import path from "node:path";
22import process from "node:process" ;
33
44import { IndiekitError } from "@indiekit/error" ;
5+ import { IndiekitStorePlugin } from "@indiekit/plugin" ;
56// eslint-disable-next-line import/default
67import bitbucket from "bitbucket" ;
78
@@ -13,7 +14,33 @@ const defaults = {
1314/**
1415 * @typedef {import("bitbucket").APIClient } APIClient
1516 */
16- export default class BitbucketStore {
17+ export default class BitbucketStorePlugin extends IndiekitStorePlugin {
18+ environment = [ "BITBUCKET_PASSWORD" ] ;
19+
20+ name = "Bitbucket store" ;
21+
22+ /**
23+ * @type {import('prompts').PromptObject[] }
24+ */
25+ prompts = [
26+ {
27+ type : "text" ,
28+ name : "user" ,
29+ message : "What is your Bitbucket username?" ,
30+ } ,
31+ {
32+ type : "text" ,
33+ name : "repo" ,
34+ message : "Which repository is your publication stored on?" ,
35+ } ,
36+ {
37+ type : "text" ,
38+ name : "branch" ,
39+ message : "Which branch are you publishing from?" ,
40+ initial : defaults . branch ,
41+ } ,
42+ ] ;
43+
1744 /**
1845 * @param {object } [options] - Plug-in options
1946 * @param {string } [options.user] - Username
@@ -22,44 +49,16 @@ export default class BitbucketStore {
2249 * @param {string } [options.password] - Password
2350 */
2451 constructor ( options = { } ) {
25- this . name = "Bitbucket store" ;
26- this . options = { ...defaults , ...options } ;
27- }
28-
29- get environment ( ) {
30- return [ "BITBUCKET_PASSWORD" ] ;
31- }
52+ super ( options ) ;
3253
33- get info ( ) {
34- const { repo, user } = this . options ;
54+ this . options = { ...defaults , ...options } ;
3555
36- return {
37- name : `${ user } /${ repo } on Bitbucket` ,
38- uid : `https://bitbucket.org/${ user } /${ repo } ` ,
56+ this . info = {
57+ name : `${ this . options . user } /${ this . options . repo } on Bitbucket` ,
58+ uid : `https://bitbucket.org/${ this . options . user } /${ this . options . repo } ` ,
3959 } ;
4060 }
4161
42- get prompts ( ) {
43- return [
44- {
45- type : "text" ,
46- name : "user" ,
47- message : "What is your Bitbucket username?" ,
48- } ,
49- {
50- type : "text" ,
51- name : "repo" ,
52- message : "Which repository is your publication stored on?" ,
53- } ,
54- {
55- type : "text" ,
56- name : "branch" ,
57- message : "Which branch are you publishing from?" ,
58- initial : defaults . branch ,
59- } ,
60- ] ;
61- }
62-
6362 /**
6463 * @access private
6564 * @returns {APIClient } Bitbucket client interface
@@ -228,8 +227,4 @@ export default class BitbucketStore {
228227 } ) ;
229228 }
230229 }
231-
232- init ( Indiekit ) {
233- Indiekit . addStore ( this ) ;
234- }
235230}
0 commit comments