New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@datocms/cli-utils

Package Overview
Dependencies
Maintainers
5
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datocms/cli-utils - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

lib/dato-profile-config-command.d.ts

6

lib/cma-client-command.d.ts
import { Client, ClientConfigOptions, LogLevel } from '@datocms/cma-client-node';
import { DatoProjectConfigCommand } from './dato-project-config-command';
import { DatoProfileConfigCommand } from './dato-profile-config-command';
export declare const logLevelMap: {

@@ -11,3 +11,3 @@ readonly NONE: LogLevel.NONE;

export declare const logLevelOptions: ("NONE" | "BASIC" | "BODY" | "BODY_AND_HEADERS")[];
export declare abstract class CmaClientCommand<T extends typeof CmaClientCommand.flags> extends DatoProjectConfigCommand<T> {
export declare abstract class CmaClientCommand<T extends typeof CmaClientCommand.flags> extends DatoProfileConfigCommand<T> {
static flags: {

@@ -17,3 +17,3 @@ 'api-token': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;

'base-url': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
project: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
profile: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
'config-file': import("@oclif/core/lib/interfaces").OptionFlag<string>;

@@ -20,0 +20,0 @@ };

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

const core_1 = require("@oclif/core");
const dato_project_config_command_1 = require("./dato-project-config-command");
const dato_profile_config_command_1 = require("./dato-profile-config-command");
const chalk = require("chalk");

@@ -16,3 +16,3 @@ exports.logLevelMap = {

exports.logLevelOptions = Object.keys(exports.logLevelMap);
class CmaClientCommand extends dato_project_config_command_1.DatoProjectConfigCommand {
class CmaClientCommand extends dato_profile_config_command_1.DatoProfileConfigCommand {
async init() {

@@ -23,6 +23,9 @@ await super.init();

buildBaseClientInitializationOptions() {
var _a, _b, _c;
const apiToken = this.parsedFlags['api-token'] || ((_a = this.datoProjectConfig) === null || _a === void 0 ? void 0 : _a.apiToken);
const baseUrl = this.parsedFlags['base-url'] || ((_b = this.datoProjectConfig) === null || _b === void 0 ? void 0 : _b.baseUrl);
const logLevelCode = this.parsedFlags['log-level'] || ((_c = this.datoProjectConfig) === null || _c === void 0 ? void 0 : _c.logLevel);
var _a, _b;
const apiTokenEnvName = this.profileId === 'default'
? `DATOCMS_API_TOKEN`
: `DATOCMS_${this.profileId.toUpperCase()}_PROFILE_API_TOKEN`;
const apiToken = this.parsedFlags['api-token'] || process.env[apiTokenEnvName];
const baseUrl = this.parsedFlags['base-url'] || ((_a = this.datoProfileConfig) === null || _a === void 0 ? void 0 : _a.baseUrl);
const logLevelCode = this.parsedFlags['log-level'] || ((_b = this.datoProfileConfig) === null || _b === void 0 ? void 0 : _b.logLevel);
const logLevel = this.parsedFlags.json || this.parsedFlags.output || !logLevelCode

@@ -35,5 +38,4 @@ ? cma_client_node_1.LogLevel.NONE

`The API token to use is determined by looking at:
* The --apiToken flag
* The DATOCMS_API_TOKEN environment variable
* Config file at "${this.datoConfigRelativePath}" (run "${this.config.bin} config:set" to setup)`,
* The --api-token flag
* The ${apiTokenEnvName} environment variable (we look inside a local ".env" file too)`,
],

@@ -76,6 +78,5 @@ });

CmaClientCommand.flags = {
...dato_project_config_command_1.DatoProjectConfigCommand.flags,
...dato_profile_config_command_1.DatoProfileConfigCommand.flags,
'api-token': core_1.Flags.string({
description: 'Specify a custom API key to access a project',
env: 'DATOCMS_API_TOKEN',
description: 'Specify a custom API key to access a DatoCMS project',
}),

@@ -82,0 +83,0 @@ 'log-level': core_1.Flags.enum({

@@ -1,3 +0,2 @@

export declare type ProjectConfig = {
apiToken?: string;
export declare type ProfileConfig = {
baseUrl?: string;

@@ -12,4 +11,4 @@ logLevel?: 'NONE' | 'BASIC' | 'BODY' | 'BODY_AND_HEADERS';

export declare type Config = {
projects: Record<string, ProjectConfig>;
profiles: Record<string, ProfileConfig>;
};
export declare function readConfig(fullPath: string): Promise<Config | undefined>;

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

const lodash_1 = require("lodash");
function isProjectConfig(thing) {
function isProfileConfig(thing) {
if (typeof thing !== 'object' || !thing) {

@@ -29,10 +29,10 @@ return false;

}
if (!('projects' in thing)) {
if (!('profiles' in thing)) {
return false;
}
const { projects } = thing;
if (typeof projects !== 'object' || !projects) {
const { profiles } = thing;
if (typeof profiles !== 'object' || !profiles) {
return false;
}
if (Object.values(projects).some((projectConfig) => !isProjectConfig(projectConfig))) {
if (Object.values(profiles).some((profileConfig) => !isProfileConfig(profileConfig))) {
return false;

@@ -39,0 +39,0 @@ }

@@ -20,3 +20,3 @@ "use strict";

suggestions: [
`Configure a local project with "${this.config.bin} config:set"`,
`Configure a local configuration profile with "${this.config.bin} profile:set"`,
],

@@ -23,0 +23,0 @@ });

@@ -0,7 +1,8 @@

import 'dotenv/config';
export * from './base-command';
export * from './cma-client-command';
export * from './dato-config-command';
export * from './dato-project-config-command';
export * from './dato-profile-config-command';
export * from './config';
export * as CmaClient from '@datocms/cma-client-node';
export * as oclif from '@oclif/core';

@@ -5,8 +5,9 @@ "use strict";

const tslib_1 = require("tslib");
require("dotenv/config");
tslib_1.__exportStar(require("./base-command"), exports);
tslib_1.__exportStar(require("./cma-client-command"), exports);
tslib_1.__exportStar(require("./dato-config-command"), exports);
tslib_1.__exportStar(require("./dato-project-config-command"), exports);
tslib_1.__exportStar(require("./dato-profile-config-command"), exports);
tslib_1.__exportStar(require("./config"), exports);
exports.CmaClient = require("@datocms/cma-client-node");
exports.oclif = require("@oclif/core");
{
"name": "@datocms/cli-utils",
"version": "0.1.8",
"version": "0.1.9",
"description": "Utils for DatoCMS CLI",

@@ -21,5 +21,6 @@ "author": "Stefano Verna <s.verna@datocms.com>",

"dependencies": {
"@datocms/cma-client-node": "^0.1.5",
"@datocms/cma-client-node": "^1",
"@oclif/core": "^1",
"chalk": "^4",
"dotenv": "^16.0.1",
"lodash": "^4.17.21"

@@ -31,3 +32,3 @@ },

},
"gitHead": "2b40a70f6d9b04815f1eb04ef8f79059efced1fa"
"gitHead": "87e3d15970872370177943224b32ed9f41c3c1c1"
}

@@ -9,3 +9,3 @@ import {

import { Flags } from '@oclif/core';
import { DatoProjectConfigCommand } from './dato-project-config-command';
import { DatoProfileConfigCommand } from './dato-profile-config-command';
import * as chalk from 'chalk';

@@ -25,8 +25,7 @@

T extends typeof CmaClientCommand.flags,
> extends DatoProjectConfigCommand<T> {
> extends DatoProfileConfigCommand<T> {
static flags = {
...DatoProjectConfigCommand.flags,
...DatoProfileConfigCommand.flags,
'api-token': Flags.string({
description: 'Specify a custom API key to access a project',
env: 'DATOCMS_API_TOKEN',
description: 'Specify a custom API key to access a DatoCMS project',
}),

@@ -52,10 +51,15 @@ 'log-level': Flags.enum<LogLevelFlagEnum>({

} {
const apiTokenEnvName =
this.profileId === 'default'
? `DATOCMS_API_TOKEN`
: `DATOCMS_${this.profileId.toUpperCase()}_PROFILE_API_TOKEN`;
const apiToken =
this.parsedFlags['api-token'] || this.datoProjectConfig?.apiToken;
this.parsedFlags['api-token'] || process.env[apiTokenEnvName];
const baseUrl =
this.parsedFlags['base-url'] || this.datoProjectConfig?.baseUrl;
this.parsedFlags['base-url'] || this.datoProfileConfig?.baseUrl;
const logLevelCode =
this.parsedFlags['log-level'] || this.datoProjectConfig?.logLevel;
this.parsedFlags['log-level'] || this.datoProfileConfig?.logLevel;

@@ -71,5 +75,4 @@ const logLevel =

`The API token to use is determined by looking at:
* The --apiToken flag
* The DATOCMS_API_TOKEN environment variable
* Config file at "${this.datoConfigRelativePath}" (run "${this.config.bin} config:set" to setup)`,
* The --api-token flag
* The ${apiTokenEnvName} environment variable (we look inside a local ".env" file too)`,
],

@@ -76,0 +79,0 @@ });

import { access, readFile } from 'fs/promises';
import { get } from 'lodash';
export type ProjectConfig = {
apiToken?: string;
export type ProfileConfig = {
baseUrl?: string;

@@ -16,6 +15,6 @@ logLevel?: 'NONE' | 'BASIC' | 'BODY' | 'BODY_AND_HEADERS';

export type Config = {
projects: Record<string, ProjectConfig>;
profiles: Record<string, ProfileConfig>;
};
function isProjectConfig(thing: any): thing is ProjectConfig {
function isProfileConfig(thing: any): thing is ProfileConfig {
if (typeof thing !== 'object' || !thing) {

@@ -46,9 +45,9 @@ return false;

if (!('projects' in thing)) {
if (!('profiles' in thing)) {
return false;
}
const { projects } = thing;
const { profiles } = thing;
if (typeof projects !== 'object' || !projects) {
if (typeof profiles !== 'object' || !profiles) {
return false;

@@ -58,4 +57,4 @@ }

if (
Object.values(projects).some(
(projectConfig) => !isProjectConfig(projectConfig),
Object.values(profiles).some(
(profileConfig) => !isProfileConfig(profileConfig),
)

@@ -62,0 +61,0 @@ ) {

@@ -40,3 +40,3 @@ import { Flags } from '@oclif/core';

suggestions: [
`Configure a local project with "${this.config.bin} config:set"`,
`Configure a local configuration profile with "${this.config.bin} profile:set"`,
],

@@ -43,0 +43,0 @@ });

@@ -0,7 +1,9 @@

import 'dotenv/config';
export * from './base-command';
export * from './cma-client-command';
export * from './dato-config-command';
export * from './dato-project-config-command';
export * from './dato-profile-config-command';
export * from './config';
export * as CmaClient from '@datocms/cma-client-node';
export * as oclif from '@oclif/core';
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