Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@adminjs/cloud-cli

Package Overview
Dependencies
Maintainers
3
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adminjs/cloud-cli - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

lib/api.d.ts

1

lib/cli.js

@@ -10,4 +10,5 @@ #! /usr/bin/env node

.option('--apiSecret <string>', 'API Secret')
.option('--config [string]', 'Configuration File')
.description('Deploy the package')
.action(commands_1.deploy)
.parseAsync(process.argv);
export declare type DeployCommandArgs = {
apiKey: string;
apiSecret: string;
config?: string;
};
declare const deploy: (opts: DeployCommandArgs) => Promise<void>;
export default deploy;

32

lib/commands/deploy.js

@@ -7,34 +7,16 @@ "use strict";

const chalk_1 = __importDefault(require("chalk"));
const axios_1 = __importDefault(require("axios"));
const form_data_1 = __importDefault(require("form-data"));
const utils_1 = require("../utils");
const api_1 = __importDefault(require("../api"));
const deploy = async (opts) => {
const { apiKey, apiSecret } = opts;
const packageJson = (0, utils_1.getPackageJSON)((0, utils_1.getPackageJSONPath)());
if (!(0, utils_1.validatePackageJson)(packageJson)) {
const { apiKey, apiSecret, config } = opts;
const configuration = (0, utils_1.loadConfiguration)((0, utils_1.getConfigurationFilePath)(config));
if (!(0, utils_1.validateConfiguration)(configuration)) {
return process.exit(1);
}
const { file, fileName, filePath } = await (0, utils_1.createArchive)(packageJson);
const data = new form_data_1.default();
data.append('file', file, {
filepath: filePath,
filename: fileName,
});
const { file, fileName, filePath } = await (0, utils_1.createArchive)(configuration);
console.log(chalk_1.default.blueBright('Uploading the package...'));
const response = await axios_1.default.post('https://adminjs-cloud-dev.adminjs.cloud/api/v1/deployments', data, {
headers: {
...(data.getHeaders() ?? {}),
'Content-Type': 'form-data',
'API-Key': apiKey,
'API-Secret': apiSecret,
},
});
if (response.data.errors) {
console.log(chalk_1.default.red(response.data.errors));
}
else {
console.log(chalk_1.default.green(response.data));
}
const api = (0, api_1.default)({ apiKey, apiSecret });
await api.deploy({ file, filePath, fileName });
await (0, utils_1.deleteArchive)(filePath);
};
exports.default = deploy;
/// <reference types="node" />
import { PackageJSONInterface } from './get-package-json';
declare const createArchive: (packageJson: PackageJSONInterface) => Promise<{
import type { CloudConfiguration } from './load-configuration';
declare const createArchive: (configuration: CloudConfiguration) => Promise<{
file: Buffer;

@@ -5,0 +5,0 @@ fileName: string;

@@ -12,5 +12,5 @@ "use strict";

const get_project_pwd_1 = __importDefault(require("./get-project-pwd"));
const createArchive = async (packageJson) => {
const createArchive = async (configuration) => {
console.log(chalk_1.default.blueBright('Packaging...'));
const { files } = packageJson;
const { include: files } = configuration;
const archive = (0, archiver_1.default)('tar', {

@@ -17,0 +17,0 @@ zlib: { level: 9 },

@@ -1,6 +0,6 @@

export { default as validatePackageJson } from './validate-package-json';
export { default as validateConfiguration } from './validate-configuration';
export { default as getProjectPwd } from './get-project-pwd';
export { default as getPackageJSON, PackageJSONInterface } from './get-package-json';
export { default as getPackageJSONPath } from './get-package-json-path';
export { default as loadConfiguration, CloudConfiguration } from './load-configuration';
export { default as getConfigurationFilePath } from './get-configuration-file-path';
export { default as createArchive } from './create-archive';
export { default as deleteArchive } from './delete-archive';

@@ -6,11 +6,11 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.deleteArchive = exports.createArchive = exports.getPackageJSONPath = exports.getPackageJSON = exports.getProjectPwd = exports.validatePackageJson = void 0;
var validate_package_json_1 = require("./validate-package-json");
Object.defineProperty(exports, "validatePackageJson", { enumerable: true, get: function () { return __importDefault(validate_package_json_1).default; } });
exports.deleteArchive = exports.createArchive = exports.getConfigurationFilePath = exports.loadConfiguration = exports.getProjectPwd = exports.validateConfiguration = void 0;
var validate_configuration_1 = require("./validate-configuration");
Object.defineProperty(exports, "validateConfiguration", { enumerable: true, get: function () { return __importDefault(validate_configuration_1).default; } });
var get_project_pwd_1 = require("./get-project-pwd");
Object.defineProperty(exports, "getProjectPwd", { enumerable: true, get: function () { return __importDefault(get_project_pwd_1).default; } });
var get_package_json_1 = require("./get-package-json");
Object.defineProperty(exports, "getPackageJSON", { enumerable: true, get: function () { return __importDefault(get_package_json_1).default; } });
var get_package_json_path_1 = require("./get-package-json-path");
Object.defineProperty(exports, "getPackageJSONPath", { enumerable: true, get: function () { return __importDefault(get_package_json_path_1).default; } });
var load_configuration_1 = require("./load-configuration");
Object.defineProperty(exports, "loadConfiguration", { enumerable: true, get: function () { return __importDefault(load_configuration_1).default; } });
var get_configuration_file_path_1 = require("./get-configuration-file-path");
Object.defineProperty(exports, "getConfigurationFilePath", { enumerable: true, get: function () { return __importDefault(get_configuration_file_path_1).default; } });
var create_archive_1 = require("./create-archive");

@@ -17,0 +17,0 @@ Object.defineProperty(exports, "createArchive", { enumerable: true, get: function () { return __importDefault(create_archive_1).default; } });

{
"name": "@adminjs/cloud-cli",
"version": "1.0.0",
"version": "1.1.0",
"description": "",

@@ -11,3 +11,4 @@ "main": "./lib/cli.js",

"test": "echo \"Error: no test specified\" && exit 1",
"release": "npx semantic-release"
"release": "npx semantic-release",
"register:local": "yarn global add file:$PWD"
},

@@ -14,0 +15,0 @@ "author": "",

@@ -10,4 +10,5 @@ #! /usr/bin/env node

.option('--apiSecret <string>', 'API Secret')
.option('--config [string]', 'Configuration File')
.description('Deploy the package')
.action(deploy)
.parseAsync(process.argv);
import chalk from 'chalk';
import axios from 'axios';
import FormData from 'form-data';
import type { PackageJSONInterface } from '../utils/get-package-json';
import {
validatePackageJson,
validateConfiguration,
deleteArchive,
getPackageJSON,
getPackageJSONPath,
loadConfiguration,
createArchive,
getConfigurationFilePath,
} from '../utils';
import ApiClient from '../api';

@@ -17,38 +15,21 @@ export type DeployCommandArgs = {

apiSecret: string;
config?: string;
};
const deploy = async (opts: DeployCommandArgs): Promise<void> => {
const { apiKey, apiSecret } = opts;
const { apiKey, apiSecret, config } = opts;
const packageJson: PackageJSONInterface = getPackageJSON(getPackageJSONPath());
const configuration = loadConfiguration(getConfigurationFilePath(config));
if (!validatePackageJson(packageJson)) {
if (!validateConfiguration(configuration)) {
return process.exit(1);
}
const { file, fileName, filePath } = await createArchive(packageJson);
const { file, fileName, filePath } = await createArchive(configuration);
const data = new FormData();
data.append('file', file, {
filepath: filePath,
filename: fileName,
});
console.log(chalk.blueBright('Uploading the package...'));
const response = await axios.post('https://adminjs-cloud-dev.adminjs.cloud/api/v1/deployments', data, {
headers: {
...(data.getHeaders() ?? {}),
'Content-Type': 'form-data',
'API-Key': apiKey,
'API-Secret': apiSecret,
},
});
const api = ApiClient({ apiKey, apiSecret });
await api.deploy({ file, filePath, fileName });
if (response.data.errors) {
console.log(chalk.red(response.data.errors));
} else {
console.log(chalk.green(response.data));
}
await deleteArchive(filePath);

@@ -55,0 +36,0 @@ };

@@ -9,9 +9,9 @@ import { lstat, readFile } from 'fs/promises';

import { PackageJSONInterface } from './get-package-json';
import getProjectPwd from './get-project-pwd';
import type { CloudConfiguration } from './load-configuration';
const createArchive = async (packageJson: PackageJSONInterface) => {
const createArchive = async (configuration: CloudConfiguration) => {
console.log(chalk.blueBright('Packaging...'));
const { files } = packageJson;
const { include: files } = configuration;

@@ -18,0 +18,0 @@ const archive = archiver('tar', {

@@ -1,6 +0,6 @@

export { default as validatePackageJson } from './validate-package-json';
export { default as validateConfiguration } from './validate-configuration';
export { default as getProjectPwd } from './get-project-pwd';
export { default as getPackageJSON, PackageJSONInterface } from './get-package-json';
export { default as getPackageJSONPath } from './get-package-json-path';
export { default as loadConfiguration, CloudConfiguration } from './load-configuration';
export { default as getConfigurationFilePath } from './get-configuration-file-path';
export { default as createArchive } from './create-archive';
export { default as deleteArchive } from './delete-archive';
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