添加账号修改,后台管理
This commit is contained in:
@@ -9,6 +9,8 @@ import {
|
||||
buildObjectKey,
|
||||
createAuthorizationHeader,
|
||||
encodeObjectKey,
|
||||
getFrontendSpaAliasContentType,
|
||||
getFrontendSpaAliasKeys,
|
||||
getCacheControl,
|
||||
getContentType,
|
||||
listFiles,
|
||||
@@ -72,11 +74,12 @@ async function uploadFile({
|
||||
endpoint,
|
||||
objectKey,
|
||||
filePath,
|
||||
contentTypeOverride,
|
||||
accessKeyId,
|
||||
accessKeySecret,
|
||||
}) {
|
||||
const body = await fs.readFile(filePath);
|
||||
const contentType = getContentType(objectKey);
|
||||
const contentType = contentTypeOverride || getContentType(objectKey);
|
||||
const date = new Date().toUTCString();
|
||||
const url = `https://${bucket}.${normalizeEndpoint(endpoint)}/${encodeObjectKey(objectKey)}`;
|
||||
const authorization = createAuthorizationHeader({
|
||||
@@ -107,6 +110,39 @@ async function uploadFile({
|
||||
}
|
||||
}
|
||||
|
||||
async function uploadSpaAliases({
|
||||
bucket,
|
||||
endpoint,
|
||||
distIndexPath,
|
||||
accessKeyId,
|
||||
accessKeySecret,
|
||||
remotePrefix,
|
||||
dryRun,
|
||||
}) {
|
||||
const aliases = getFrontendSpaAliasKeys();
|
||||
const contentType = getFrontendSpaAliasContentType();
|
||||
|
||||
for (const alias of aliases) {
|
||||
const objectKey = buildObjectKey(remotePrefix, alias);
|
||||
|
||||
if (dryRun) {
|
||||
console.log(`[dry-run] upload alias ${alias} -> ${objectKey}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
await uploadFile({
|
||||
bucket,
|
||||
endpoint,
|
||||
objectKey,
|
||||
filePath: distIndexPath,
|
||||
contentTypeOverride: contentType,
|
||||
accessKeyId,
|
||||
accessKeySecret,
|
||||
});
|
||||
console.log(`uploaded alias ${objectKey}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const {dryRun, skipBuild} = parseArgs(process.argv.slice(2));
|
||||
|
||||
@@ -146,6 +182,16 @@ async function main() {
|
||||
});
|
||||
console.log(`uploaded ${objectKey}`);
|
||||
}
|
||||
|
||||
await uploadSpaAliases({
|
||||
bucket,
|
||||
endpoint,
|
||||
distIndexPath: path.join(distDir, 'index.html'),
|
||||
accessKeyId,
|
||||
accessKeySecret,
|
||||
remotePrefix,
|
||||
dryRun,
|
||||
});
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
|
||||
Reference in New Issue
Block a user