Skip to content

Commit

Permalink
feat: adds haikunator strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
moltar committed Sep 14, 2022
1 parent f968440 commit c33b3ac
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/naming-strategy/naming-strategy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Haikunator, { Options as HaikunatorOptions } from 'haikunator';
import { paramCase } from 'param-case';
import { IStaticWebsitePreviewNamingToken } from './tokens';

Expand All @@ -8,6 +9,7 @@ export interface IStaticWebsitePreviewNamingStrategy {
name: string;
}


export class StaticWebsitePreviewNamingStrategy implements IStaticWebsitePreviewNamingStrategy {
/**
* Set a static name for your deployment.
Expand All @@ -23,6 +25,17 @@ export class StaticWebsitePreviewNamingStrategy implements IStaticWebsitePreview
return new StaticWebsitePreviewNamingStrategy(tokens.map(({ token }) => token).join('-'));
}

/**
* Uses the Haikunator package to generate a random name, Heroku-style.
*
* @see https://www.npmjs.com/package/haikunator
*/
static fromHaikunator(options?: HaikunatorOptions): IStaticWebsitePreviewNamingStrategy {
return new StaticWebsitePreviewNamingStrategy(
new Haikunator(options).haikunate(),
);
}

/**
* Sub-domain that will be used to host the preview.
*/
Expand Down

0 comments on commit c33b3ac

Please sign in to comment.