Skip to content

Commit c1fa5e3

Browse files
committed
1.0.8 release
1 parent 01f899b commit c1fa5e3

File tree

146 files changed

+8323
-47650
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+8323
-47650
lines changed

dist/index.js

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,62 @@
1-
import * as core from '@actions/core';
2-
import { getFilesForUpload } from './src/file-system-utils';
3-
import { uploadAll } from './src/azure-upload-utils';
1+
"use strict";
2+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3+
if (k2 === undefined) k2 = k;
4+
var desc = Object.getOwnPropertyDescriptor(m, k);
5+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6+
desc = { enumerable: true, get: function() { return m[k]; } };
7+
}
8+
Object.defineProperty(o, k2, desc);
9+
}) : (function(o, m, k, k2) {
10+
if (k2 === undefined) k2 = k;
11+
o[k2] = m[k];
12+
}));
13+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14+
Object.defineProperty(o, "default", { enumerable: true, value: v });
15+
}) : function(o, v) {
16+
o["default"] = v;
17+
});
18+
var __importStar = (this && this.__importStar) || function (mod) {
19+
if (mod && mod.__esModule) return mod;
20+
var result = {};
21+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22+
__setModuleDefault(result, mod);
23+
return result;
24+
};
25+
Object.defineProperty(exports, "__esModule", { value: true });
26+
var core = __importStar(require("@actions/core"));
27+
var file_system_utils_1 = require("./src/file-system-utils");
28+
var azure_upload_utils_1 = require("./src/azure-upload-utils");
429
try {
530
/**
631
* File types to upload should look like
732
* { ".html": "text/html" }
833
*/
9-
const fileTypesToUpload = JSON.parse(core.getInput('fileTypesToUpload'));
34+
var fileTypesToUpload_1 = JSON.parse(core.getInput('fileTypesToUpload'));
1035
/**
1136
* Directories to upload should look like
1237
* [
1338
* { directoryToUpload: "", shouldRecurse: "", baseContainerPath: "" }
1439
* ]
1540
*/
16-
const directoriesToUpload = JSON.parse(core.getInput('directoriesToUpload')) || [];
17-
let filesToUpload = [];
18-
directoriesToUpload.forEach(t => {
19-
filesToUpload = filesToUpload.concat(getFilesForUpload(t.directoryToUpload, t.shouldRecurse, t.baseContainerPath, Object.keys(fileTypesToUpload)));
41+
var directoriesToUpload = JSON.parse(core.getInput('directoriesToUpload')) || [];
42+
var filesToUpload_1 = [];
43+
directoriesToUpload.forEach(function (t) {
44+
filesToUpload_1 = filesToUpload_1.concat((0, file_system_utils_1.getFilesForUpload)(t.directoryToUpload, t.shouldRecurse, t.baseContainerPath, Object.keys(fileTypesToUpload_1)));
2045
});
2146
/**
2247
* Azure Blob Configurations should look like
2348
* [
2449
* { connectionString: "", container: "" }
2550
* ]
2651
*/
27-
const entraAppConfiguration = {
52+
var entraAppConfiguration = {
2853
clientId: core.getInput('clientId'),
2954
clientSecret: core.getInput('clientSecret'),
3055
tenantId: core.getInput('tenantId')
3156
};
32-
const storageAccountList = JSON.parse(core.getInput('storageAccountList'));
33-
const containerName = core.getInput('containerName');
34-
uploadAll(storageAccountList, containerName, entraAppConfiguration, filesToUpload, fileTypesToUpload);
57+
var storageAccountList = JSON.parse(core.getInput('storageAccountList'));
58+
var containerName = core.getInput('containerName');
59+
(0, azure_upload_utils_1.uploadAll)(storageAccountList, containerName, entraAppConfiguration, filesToUpload_1, fileTypesToUpload_1);
3560
}
3661
catch (error) {
3762
core.setFailed(error.message);

dist/src/azure-upload-utils.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
import path from 'path';
2-
import fs from 'fs';
3-
import { BlobServiceClient } from '@azure/storage-blob';
4-
import { ClientSecretCredential } from '@azure/identity';
5-
export function uploadAll(storageAccountList, containerName, entraAppConfiguration, filesToUpload, supportedContentTypes) {
6-
storageAccountList.forEach(account => {
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
exports.uploadAll = void 0;
7+
var path_1 = __importDefault(require("path"));
8+
var fs_1 = __importDefault(require("fs"));
9+
var storage_blob_1 = require("@azure/storage-blob");
10+
var identity_1 = require("@azure/identity");
11+
function uploadAll(storageAccountList, containerName, entraAppConfiguration, filesToUpload, supportedContentTypes) {
12+
storageAccountList.forEach(function (account) {
713
// Storage account URL
8-
const blobServiceClientUrl = `https://${account}.blob.core.windows.net`;
9-
const credential = new ClientSecretCredential(entraAppConfiguration.tenantId, entraAppConfiguration.clientId, entraAppConfiguration.clientSecret);
10-
const blobServiceClient = new BlobServiceClient(blobServiceClientUrl, credential);
14+
var blobServiceClientUrl = "https://".concat(account, ".blob.core.windows.net");
15+
var credential = new identity_1.ClientSecretCredential(entraAppConfiguration.tenantId, entraAppConfiguration.clientId, entraAppConfiguration.clientSecret);
16+
var blobServiceClient = new storage_blob_1.BlobServiceClient(blobServiceClientUrl, credential);
1117
// Get a reference to the container
12-
const containerClient = blobServiceClient.getContainerClient(containerName);
13-
filesToUpload.forEach(x => {
14-
let stream = fs.readFileSync(x.absoluteDiskPath);
15-
let contentType = supportedContentTypes[path.extname(x.absoluteDiskPath)];
18+
var containerClient = blobServiceClient.getContainerClient(containerName);
19+
filesToUpload.forEach(function (x) {
20+
var stream = fs_1.default.readFileSync(x.absoluteDiskPath);
21+
var contentType = supportedContentTypes[path_1.default.extname(x.absoluteDiskPath)];
1622
if (!contentType)
17-
throw `Unsupported Content Type for ${x.absoluteDiskPath}`;
23+
throw "Unsupported Content Type for ".concat(x.absoluteDiskPath);
1824
containerClient.uploadBlockBlob(x.relativeUploadPath, stream, stream.length, { blobHTTPHeaders: { blobContentType: contentType } });
1925
});
2026
});
2127
}
28+
exports.uploadAll = uploadAll;

dist/src/file-system-utils.js

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
import fs from 'fs';
2-
import Queue from 'queue-fifo';
3-
import path from 'path';
4-
let q = new Queue();
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
exports.getFilesForUpload = void 0;
7+
var fs_1 = __importDefault(require("fs"));
8+
var queue_fifo_1 = __importDefault(require("queue-fifo"));
9+
var path_1 = __importDefault(require("path"));
10+
var q = new queue_fifo_1.default();
511
/**
612
* Traverses the disk and builds a list/map of which files to upload and with what relative paths.
713
*
@@ -13,42 +19,46 @@ let q = new Queue();
1319
* @returns an array of objects which carry absolute path on disk
1420
* and where they would be uploaded in cloud
1521
*/
16-
export function getFilesForUpload(scanDirectory, shouldRecurse, baseContainerPath, extensionsToUpload) {
17-
let filesToUpload = [];
22+
function getFilesForUpload(scanDirectory, shouldRecurse, baseContainerPath, extensionsToUpload) {
23+
var filesToUpload = [];
1824
q.enqueue(scanDirectory);
19-
while (!q.isEmpty()) {
20-
const currentDirectoryPath = q.dequeue();
25+
var _loop_1 = function () {
26+
var currentDirectoryPath = q.dequeue();
2127
console.log('Traversing directory: ', currentDirectoryPath);
22-
const currentDirectoryContents = fs.readdirSync(currentDirectoryPath);
23-
const filesInCurrentDirectory = currentDirectoryContents
28+
var currentDirectoryContents = fs_1.default.readdirSync(currentDirectoryPath);
29+
var filesInCurrentDirectory = currentDirectoryContents
2430
// filter for files only
25-
.filter(t => !fs.lstatSync(path.join(currentDirectoryPath, t)).isDirectory())
31+
.filter(function (t) { return !fs_1.default.lstatSync(path_1.default.join(currentDirectoryPath, t)).isDirectory(); })
2632
// filenames to full path
27-
.map(t => path.join(currentDirectoryPath, t));
28-
console.log(`Files in ${currentDirectoryPath}`, filesInCurrentDirectory);
29-
let uploadCandidates = filesInCurrentDirectory
33+
.map(function (t) { return path_1.default.join(currentDirectoryPath, t); });
34+
console.log("Files in ".concat(currentDirectoryPath), filesInCurrentDirectory);
35+
var uploadCandidates = filesInCurrentDirectory
3036
// make sure we only target the specified extensions
31-
.filter(t => extensionsToUpload.some(x => t.endsWith(x)));
32-
console.log(`Upload candidates from ${currentDirectoryPath}`, uploadCandidates);
33-
filesToUpload.push(...uploadCandidates);
37+
.filter(function (t) { return extensionsToUpload.some(function (x) { return t.endsWith(x); }); });
38+
console.log("Upload candidates from ".concat(currentDirectoryPath), uploadCandidates);
39+
filesToUpload.push.apply(filesToUpload, uploadCandidates);
3440
if (shouldRecurse) {
35-
let dirsInDir = currentDirectoryContents
36-
.filter(t => fs.lstatSync(path.join(currentDirectoryPath, t))
41+
var dirsInDir = currentDirectoryContents
42+
.filter(function (t) { return fs_1.default.lstatSync(path_1.default.join(currentDirectoryPath, t))
3743
// this time, query for directories only
38-
.isDirectory()).map(t => path.join(currentDirectoryPath, t));
44+
.isDirectory(); }).map(function (t) { return path_1.default.join(currentDirectoryPath, t); });
3945
if (dirsInDir && dirsInDir.length) {
4046
// enqueue directories, continue traversing
41-
dirsInDir.forEach(t => q.enqueue(t));
47+
dirsInDir.forEach(function (t) { return q.enqueue(t); });
4248
}
4349
}
50+
};
51+
while (!q.isEmpty()) {
52+
_loop_1();
4453
}
45-
let uploadStructure = filesToUpload.map(t => {
46-
let relativePath = t.replace(scanDirectory, '');
54+
var uploadStructure = filesToUpload.map(function (t) {
55+
var relativePath = t.replace(scanDirectory, '');
4756
if (relativePath[0] === '/')
4857
relativePath = relativePath.substring(1);
4958
if (baseContainerPath !== undefined)
50-
relativePath = `${baseContainerPath}/${relativePath}`;
59+
relativePath = "".concat(baseContainerPath, "/").concat(relativePath);
5160
return { absoluteDiskPath: t, relativeUploadPath: relativePath };
5261
});
5362
return uploadStructure;
5463
}
64+
exports.getFilesForUpload = getFilesForUpload;

node_modules/.package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@types/node/README.md

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)