Skip to content

Commit

Permalink
fix: publishing doesn't work (#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
vsesh authored Aug 14, 2023
1 parent 4d4b195 commit 3cf4bc1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/cmd/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,16 +252,24 @@ async function handler(args: Arguments<any>) {
if (publish) {
const DEFAULT_PREFIX = process.env.YFM_STORAGE_PREFIX ?? '';
const {
output,
ignore = [],
storageRegion,
storageEndpoint: endpoint,
storageBucket: bucket,
storagePrefix: prefix = DEFAULT_PREFIX,
storageKeyId: accessKeyId,
storageSecretKey: secretAccessKey,
} = ArgvService.getConfig();

await publishFilesToS3({
output, ignore, endpoint, bucket, prefix, accessKeyId, secretAccessKey,
input: userOutputFolder,
region: storageRegion,
ignore,
endpoint,
bucket,
prefix,
accessKeyId,
secretAccessKey,
});
}
}
Expand Down
13 changes: 12 additions & 1 deletion src/cmd/publish/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@ import mime from 'mime-types';
import {convertBackSlashToSlash, logger} from '../../utils';
import {asyncify, mapLimit} from 'async';

export async function upload(props): Promise<void> {
interface UploadProps {
input: string;
ignore: string[];
endpoint: string;
bucket: string;
prefix: string;
accessKeyId: string;
secretAccessKey: string;
region: string;
}

export async function upload(props: UploadProps): Promise<void> {
const {
input,
ignore = [],
Expand Down
1 change: 1 addition & 0 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface YfmArgv extends YfmConfig {
storagePrefix: string;
storageKeyId: string;
storageSecretKey: string;
storageRegion: string;
contributors: boolean;
ignoreAuthorPatterns: string;
addSystemMeta: boolean;
Expand Down
5 changes: 5 additions & 0 deletions src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ const validators: Record<string, ConnectorValidatorProps> = {
validateFn: notEmptyStringValidator,
defaultValue: process.env.YFM_STORAGE_SECRET_KEY,
},
'storageRegion': {
errorMessage: 'Region of S3 storage must be provided when publishes.',
validateFn: notEmptyStringValidator,
defaultValue: 'eu-central-1',
},
};

interface Redirect {
Expand Down

0 comments on commit 3cf4bc1

Please sign in to comment.