Skip to content

Commit

Permalink
feat(new): generate Private Packagist token
Browse files Browse the repository at this point in the history
  • Loading branch information
codepuncher committed Dec 15, 2023
1 parent c39b843 commit 76a25ba
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/commands/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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

Check failure on line 237 in src/commands/new.ts

View workflow job for this annotation

GitHub Actions / Node 18

'trellisPackagistToken' is assigned a value but never used
ux.action.stop()
}

// Generate a SendGrid API key
if (sendgrid) {
ux.action.start('Creating SendGrid API key')
Expand Down

0 comments on commit 76a25ba

Please sign in to comment.