Socket
Socket
Sign inDemoInstall

@uxpin/storybook-deployer

Package Overview
Dependencies
Maintainers
6
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uxpin/storybook-deployer - npm Package Compare versions

Comparing version 1.0.1-dev.169 to 1.0.1-dev.170

5

package.json
{
"name": "@uxpin/storybook-deployer",
"version": "1.0.1-dev.169",
"version": "1.0.1-dev.170",
"description": "CLI to deploy static Storybook to UXPin",

@@ -39,4 +39,5 @@ "main": "src/deploy.js",

"form-data": "^4.0.0",
"mime-types": "^2.1.35"
"mime-types": "^2.1.35",
"node-dig-dns": "^0.3.3"
}
}

86

src/deploy.js

@@ -61,4 +61,6 @@ "use strict";

var mime_types_1 = __importDefault(require("mime-types"));
var UXPIN_DOMAIN = 'uxpin.com';
var AUTH_TOKEN_HEADER_NAME = 'auth-token';
// @ts-ignore
var node_dig_dns_1 = __importDefault(require("node-dig-dns"));
var UXPIN_DOMAIN = "uxpin.com";
var AUTH_TOKEN_HEADER_NAME = "auth-token";
var latestCommitHash;

@@ -76,13 +78,24 @@ function deploy(args) {

libraryHash = (_a.sent()).libraryHash;
console.log("Library hash", libraryHash);
console.log("Start uploading", Date.now());
return [4 /*yield*/, getPresignedS3PostUrl(args)];
case 2:
presignedS3PostUrlResponse = _a.sent();
console.log(presignedS3PostUrlResponse);
(0, node_dig_dns_1.default)([presignedS3PostUrlResponse.url])
.then(function (result) {
console.log("Presigned url - dig result", result);
})
.catch(function (err) {
console.log("Error presigned url:", err);
});
return [4 /*yield*/, deployStorybookToS3(args, libraryHash, presignedS3PostUrlResponse)];
case 3:
_a.sent();
console.log('Updating commit hash on UXPin...');
console.log("Updating commit hash on UXPin...");
console.log("End uploading", Date.now());
return [4 /*yield*/, updateCommitHash(args)];
case 4:
_a.sent();
storybookUrl = (0, path_1.join)(getBaseUrl(args.uxpinDomain), 'libraries-storybook', libraryHash, 'index.html');
storybookUrl = (0, path_1.join)(getBaseUrl(args.uxpinDomain), "libraries-storybook", libraryHash, "index.html");
console.log(chalk_1.default.green("\u2705 DONE! Your storybook is available on " + storybookUrl));

@@ -92,3 +105,6 @@ return [3 /*break*/, 6];

error_1 = _a.sent();
typeof (error_1) === 'string' ? console.log(chalk_1.default.red(error_1)) : console.log(error_1);
console.log("End uploading", Date.now());
typeof error_1 === "string"
? console.log(chalk_1.default.red(error_1))
: console.log(error_1);
return [3 /*break*/, 6];

@@ -110,4 +126,6 @@ case 6: return [2 /*return*/];

url = getBaseUrl(args.uxpinDomain) + "/libraries-storybook/getLibraryHashByToken";
return [2 /*return*/, axiosWithEnhancedError({ url: url, headers: (_a = {}, _a[AUTH_TOKEN_HEADER_NAME] = args.token, _a.method = 'GET', _a) })
.then(function (res) { return res.data; })];
return [2 /*return*/, axiosWithEnhancedError({
url: url,
headers: (_a = {}, _a[AUTH_TOKEN_HEADER_NAME] = args.token, _a.method = "GET", _a),
}).then(function (res) { return res.data; })];
});

@@ -122,4 +140,7 @@ });

url = getBaseUrl(args.uxpinDomain) + "/libraries-storybook/getPresignedS3PostUrl/" + latestCommitHash;
return [2 /*return*/, axiosWithEnhancedError({ url: url, headers: (_a = {}, _a[AUTH_TOKEN_HEADER_NAME] = args.token, _a.method = 'GET', _a) })
.then(function (res) { return res.data; })];
console.log("getPresignedS3PostUrl", url);
return [2 /*return*/, axiosWithEnhancedError({
url: url,
headers: (_a = {}, _a[AUTH_TOKEN_HEADER_NAME] = args.token, _a.method = "GET", _a),
}).then(function (res) { return res.data; })];
});

@@ -143,3 +164,3 @@ });

list.forEach(function (fileOrDir) {
fileOrDir = source + '/' + fileOrDir;
fileOrDir = source + "/" + fileOrDir;
var stat = (0, fs_1.statSync)(fileOrDir);

@@ -160,3 +181,3 @@ if (stat && stat.isDirectory()) {

return __generator(this, function (_a) {
console.log('Start uploading Storybook assets...');
console.log("Start uploading Storybook assets...");
s3Prefix = getS3Prefix(libraryHash);

@@ -173,18 +194,21 @@ promises = getFilesList(args.source).map(function (absFilePath) { return __awaiter(_this, void 0, void 0, function () {

});
form.append('key', key);
form.append('Content-Type', mime_types_1.default.contentType(mime_types_1.default.lookup(absFilePath) || 'application/octet-stream'));
form.append('file', (0, fs_1.createReadStream)(absFilePath));
return [2 /*return*/, new Promise(function (resolve, reject) { return form.submit(presignedS3urlResponse.url, function (err, data) {
if (err) {
reject(err);
}
else if (data.statusCode !== 204) {
reject({
status: data.statusCode,
statusMessage: data.statusMessage,
filePath: relativePath,
});
}
resolve();
}); })];
form.append("key", key);
form.append("Content-Type", mime_types_1.default.contentType(mime_types_1.default.lookup(absFilePath) || "application/octet-stream"));
console.log("File", absFilePath, mime_types_1.default.lookup(absFilePath));
form.append("file", (0, fs_1.createReadStream)(absFilePath));
return [2 /*return*/, new Promise(function (resolve, reject) {
return form.submit(presignedS3urlResponse.url, function (err, data) {
if (err) {
reject(err);
}
else if (data.statusCode !== 204) {
reject({
status: data.statusCode,
statusMessage: data.statusMessage,
filePath: relativePath,
});
}
resolve();
});
})];
});

@@ -203,4 +227,8 @@ }); });

data = { commitHash: latestCommitHash };
return [2 /*return*/, axiosWithEnhancedError({ url: url, data: data, headers: (_a = {}, _a[AUTH_TOKEN_HEADER_NAME] = args.token, _a), method: 'PUT' })
.then(function () { return true; })];
return [2 /*return*/, axiosWithEnhancedError({
url: url,
data: data,
headers: (_a = {}, _a[AUTH_TOKEN_HEADER_NAME] = args.token, _a),
method: "PUT",
}).then(function () { return true; })];
});

@@ -207,0 +235,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc