-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new): generate Private Packagist token
- Loading branch information
1 parent
c39b843
commit 76a25ba
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,6 +152,18 @@ export default class New extends Command { | |
description: 'whether or not to create a Private Packagist token for the new project', | ||
default: true, | ||
}), | ||
packagist_api_key: Flags.string({ | ||
description: 'The API key', | ||
env: 'IROOTS_PACKAGIST_API_KEY', | ||
required: true, | ||
dependsOn: ['packagist'], | ||
}), | ||
packagist_api_secret: Flags.string({ | ||
description: 'The API SECRET', | ||
env: 'IROOTS_PACKAGIST_API_SECRET', | ||
required: true, | ||
dependsOn: ['packagist'], | ||
}), | ||
sendgrid: Flags.boolean({ | ||
description: 'whether or not to create a SendGrid API key for the new project', | ||
default: true, | ||
|
@@ -192,6 +204,9 @@ export default class New extends Command { | |
trellis_template_vault_pass, | ||
multisite, | ||
network_media_library_site_id, | ||
packagist, | ||
packagist_api_key, | ||
packagist_api_secret, | ||
sendgrid, | ||
sendgrid_api_key, | ||
} = flags | ||
|
@@ -207,6 +222,22 @@ export default class New extends Command { | |
const {owner: trellisRemoteOwner, repo: trellisRemoteRepo} = await git.parseRemote(trellis_remote) | ||
const trellisRemote = `[email protected]:${trellisRemoteOwner}/${trellisRemoteRepo}` | ||
|
||
// Generate a Private Packagist token | ||
if (packagist) { | ||
ux.action.start('Creating Packagist API key') | ||
const response = await createToken(packagist_api_key, packagist_api_secret, { | ||
description: trellisRemoteRepo, | ||
access: 'read', | ||
accessToAllPackages: true, | ||
}) | ||
if (response.status === 'error' || !response.token) { | ||
this.error(response.message.trim()) | ||
} | ||
|
||
const trellisPackagistToken = response.token | ||
ux.action.stop() | ||
} | ||
|
||
// Generate a SendGrid API key | ||
if (sendgrid) { | ||
ux.action.start('Creating SendGrid API key') | ||
|