Giter Site home page Giter Site logo

cli's People

Contributors

abhinav-from-contentstack avatar abhnv101 avatar akashbhosale97 avatar almeida-shrutika avatar aman1908 avatar aman19k avatar antonyagustine avatar aravindbuilt avatar contentstack-admin avatar cs-raj avatar hiteshshetty-dev avatar jayesh2812 avatar michaeled avatar nandeesh-gajula avatar netrajpatel avatar rohitmishra209 avatar sachinkalecs avatar shafeeqd959 avatar snyk-bot avatar vkalta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cli's Issues

csdx stack export failing

The csdx stack export is failing with the following error:

csdx cm:stacks:export -a token -d . --branch main --module entries

 Currently using NA region

node:internal/process/promises:279
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "You do not have permissions to perform this action, please login to proceed".] {
  code: 'ERR_UNHANDLED_REJECTION'

csdx version info:

csdx --help
   ____            _             _       _             _
  / ___|___  _ __ | |_ ___ _ __ | |_ ___| |_ __ _  ___| | __
 | |   / _ \| '_ \| __/ _ \ '_ \| __/ __| __/ _` |/ __| |/ /
 | |__| (_) | | | | ||  __/ | | | |_\__ \ || (_| | (__|   <
  \____\___/|_| |_|\__\___|_| |_|\__|___/\__\__,_|\___|_|\_\

Command-line tool (CLI) to interact with Contentstack

VERSION
  @contentstack/cli/1.3.0 darwin-x64 node-v16.15.1

Deprecation Warning when using node@21 when running import command.

When running the csdx cm:stacks:import command using node v21.4.0 I get a deprecation warning (which doesn't occur with v20 or lower).

While this isn't an error, the package will be deprecated soon and you might want to investigate alternative options.

[DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

Importing a single module does not work

If you try to import just a single module rather than all modules, you will get the following error:

(node:13856) UnhandledPromiseRejectionWarning: ReferenceError: stackDetails is not defined
    at C:\Users\...\AppData\Roaming\npm\node_modules\@contentstack\cli\node_modules\@contentstack\cli-cm-import\src\app.js:68:9
    at new Promise (<anonymous>)
    at singleImport (C:\Users\...\AppData\Roaming\npm\node_modules\@contentstack\cli\node_modules\@contentstack\cli-cm-import\src\app.js:65:10)
    at C:\Users\...\AppData\Roaming\npm\node_modules\@contentstack\cli\node_modules\@contentstack\cli-cm-import\src\app.js:40:19
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:13856) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:13856) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This appears to be because there is a still a reference to the stackDetails function in the mentioned app.js file, but that function itself has been removed in a previous commit.

Use the following command to test against some exported content:

csdx cm:import -A -m content-types

Migration fails if www.google-analytics.com is blocked

I am blocking all the outgoing connections to google analytics and as a result this CLI fails because it fails to connect to Google Analytics.

Here are the debug logs

follow-redirects options {
  maxRedirects: 21,
  maxBodyLength: 10485760,
  protocol: 'http:',
  path: '/collect',
  method: 'POST',
  headers: {
    Accept: 'application/json, text/plain, */*',
    'Content-Type': 'application/x-www-form-urlencoded',
    'User-Agent': 'axios/0.21.4',
    'Content-Length': 211
  },
  agent: undefined,
  agents: { http: undefined, https: undefined },
  auth: undefined,
  hostname: 'www.google-analytics.com',
  port: null,
  nativeProtocols: {
    'http:': {
      _connectionListener: [Function: connectionListener],
      METHODS: [Array],
      STATUS_CODES: [Object],
      Agent: [Function],
      ClientRequest: [Function: ClientRequest],
      IncomingMessage: [Function: IncomingMessage],
      OutgoingMessage: [Function: OutgoingMessage],
      Server: [Function: Server],
      ServerResponse: [Function: ServerResponse],
      createServer: [Function: createServer],
      validateHeaderName: [Function: __node_internal_],
      validateHeaderValue: [Function: __node_internal_],
      get: [Function: get],
      request: [Function: request],
      maxHeaderSize: [Getter],
      globalAgent: [Getter/Setter]
    },
    'https:': {
      Agent: [Function: Agent],
      globalAgent: [Agent],
      Server: [Function: Server],
      createServer: [Function: createServer],
      get: [Function: get],
      request: [Function: request]
    }
  }
}

and the error:

(node:52143) [ECONNREFUSED] Error Plugin: @contentstack/cli: connect ECONNREFUSED :::80
module: @oclif/[email protected]
task: runHook prerun
plugin: @contentstack/cli
root: /Users/<myuser>/.nvm/versions/node/v17.0.1/lib/node_modules/@contentstack/cli
See more details with DEBUG=*
(Use `node --trace-warnings ...` to show where the warning was created)
Error: connect ECONNREFUSED :::80
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16)
module: @oclif/[email protected]
task: runHook prerun
plugin: @contentstack/cli

Install script fails

Tested on several versions of Node:

This is out dated script we will update it soon.
cp: dependency: No such file or directory
audited 721 packages in 2.845s

52 packages are looking for funding
  run `npm fund` for details

found 2 moderate severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details
lerna notice cli v5.1.6
lerna info versioning independent
lerna info Bootstrapping 13 packages
lerna info Symlinking packages and binaries
lerna success Bootstrapped 13 packages
lerna notice cli v5.1.6
lerna info versioning independent
lerna info Executing command in 2 packages: "npm run pack"
lerna info run Ran npm script 'pack' in '@contentstack/cli-cm-import' in 2.2s:

> @contentstack/[email protected] prepack /Users/user/code/csdx-source/packages/contentstack-import
> oclif-dev manifest && oclif-dev readme

wrote manifest to /Users/user/code/csdx-source/packages/contentstack-import/oclif.manifest.json
replacing <!-- usage --> in README.md
replacing <!-- commands --> in README.md
replacing <!-- toc --> in README.md

> @contentstack/[email protected] pack /Users/user/code/csdx-source/packages/contentstack-import
> npm pack && mv *.tgz ../../build


> @contentstack/[email protected] prepack /Users/user/code/csdx-source/packages/contentstack-import
> oclif-dev manifest && oclif-dev readme

wrote manifest to /Users/user/code/csdx-source/packages/contentstack-import/oclif.manifest.json
replacing <!-- usage --> in README.md
replacing <!-- commands --> in README.md
replacing <!-- toc --> in README.md

> @contentstack/[email protected] postpack /Users/user/code/csdx-source/packages/contentstack-import
> rm -f oclif.manifest.json

contentstack-cli-cm-import-0.1.1-beta.18.tgz

> @contentstack/[email protected] postpack /Users/user/code/csdx-source/packages/contentstack-import
> rm -f oclif.manifest.json

lerna info run Ran npm script 'pack' in '@contentstack/cli-cm-seed' in 12.8s:

> @contentstack/[email protected] prepack /Users/user/code/csdx-source/packages/contentstack-seed
> rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme

wrote manifest to /Users/user/code/csdx-source/packages/contentstack-seed/oclif.manifest.json
replacing <!-- commands --> in README.md

> @contentstack/[email protected] pack /Users/user/code/csdx-source/packages/contentstack-seed
> npm pack --dry-run


> @contentstack/[email protected] prepack /Users/user/code/csdx-source/packages/contentstack-seed
> rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme

wrote manifest to /Users/user/code/csdx-source/packages/contentstack-seed/oclif.manifest.json
replacing <!-- commands --> in README.md

> @contentstack/[email protected] postpack /Users/user/code/csdx-source/packages/contentstack-seed
> rm -f oclif.manifest.json

contentstack-cli-cm-seed-1.0.11.tgz

> @contentstack/[email protected] postpack /Users/user/code/csdx-source/packages/contentstack-seed
> rm -f oclif.manifest.json

lerna success run Ran npm script 'pack' in 2 packages in 15.0s:
lerna success - @contentstack/cli-cm-import
lerna success - @contentstack/cli-cm-seed
Building CLI package...
lerna notice cli v5.1.6
lerna info versioning independent
lerna info Executing command in 1 package: "npm run build"
lerna info run Ran npm script 'build' in '@contentstack/cli-cm-bootstrap' in 4.4s:

> @contentstack/[email protected] build /Users/user/code/csdx-source/packages/contentstack-bootstrap
> npm run clean && npm run compile


> @contentstack/[email protected] clean /Users/user/code/csdx-source/packages/contentstack-bootstrap
> rm -rf ./lib && rm -rf tsconfig.build.tsbuildinfo


> @contentstack/[email protected] compile /Users/user/code/csdx-source/packages/contentstack-bootstrap
> tsc -b tsconfig.json

lerna success run Ran npm script 'build' in 1 package in 4.4s:
lerna success - @contentstack/cli-cm-bootstrap
Built CLI package, Done!!!
./install-from-code.sh: line 32: cd: build/@contentstack/packages: No such file or directory
Installing Contentstack CLI globally
npm ERR! code ENOENT
npm ERR! syscall stat
npm ERR! path /Users/user/code/csdx-source/contentstack-cli.tgz
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, stat '/Users/user/code/csdx-source/contentstack-cli.tgz'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/user/.npm/_logs/2022-07-08T11_40_16_426Z-debug.log
\e[31mGlobal installation failed for CLI module!!!```

Import content-types module fails

When I run csdx import command:
csdx cm:import -a import-token -d production-export -m content-types

I'm getting an error saying that the content-type title already exists and therefore it won't create it and fails to proceed.

See error below:

{
  "status": 422,
  "statusText": "Unprocessable Entity",
  "request": {
    "url": "/content_types",
    "method": "post",
    "data": "{\"content_type\":{\"title\":\"contact_information\",\"uid\":\"contact_information\",\"schema\":[{\"display_name\":\"Title\",\"uid\":\"title\",\"data_type\":\"text\",\"field_metadata\":{\"_default\":true},\"unique\":false,\"mandatory\":true,\"multiple\":false},{\"display_name\":\"URL\",\"uid\":\"url\",\"data_type\":\"text\",\"field_metadata\":{\"_default\":true},\"unique\":false,\"multiple\":false}],\"options\":{\"title\":\"title\",\"publishable\":true,\"is_page\":true,\"singleton\":false,\"sub_title\":[\"url\"],\"url_pattern\":\"/:title\",\"url_prefix\":\"/\"}}}",
    "headers": {
      "Accept": "application/json, text/plain, */*",
      "Content-Type": "application/json;charset=utf-8",
      "X-User-Agent": "contentstack-management-javascript/1.2.4",
      "User-Agent": "sdk contentstack-management-javascript/1.2.4; platform node.js/v15.4.0; os macOS/20.6.0;",
      "api_key": "bltb5839af18a3f5a96",
      "authorization": "...9309c",
      "Content-Length": 491
    }
  },
  "errorMessage": "Content Type creation failed. Please try again.",
  "errorCode": 115,
  "errors": { "title": ["is not unique."] }
}

error: The log for this is stored at production-export/logs/import
node:internal/process/promises:227
          triggerUncaughtException(err, true /* fromPromise */);
          ^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".] {
  code: 'ERR_UNHANDLED_REJECTION'

I did some investigation and found out that the import script is first importing the uid as title for the content-types. Then it's failing with this weird issue. It seems an async problem that is blocking the execution to proceed, because it first adds the content type and then tries to update it, but before that it already fails.
When I log in, I see some content types there, but they're all using their uid's as title.

Context:
The content types I'm trying to import are exported from another stack, with same configurations (master locale, languages, environments, etc). This issue is happening on csdx version: [email protected]

It works fine on [email protected]. I was trying to update the version to the latest one, but I found this blocker and decide to open this issue.

Here's an example of content-type being imported that fails: https://www.codepile.net/pile/eG7MaXmY

cm:stacks:seed results in error

I try to follow the starter tutorial at https://www.contentstack.com/docs/developers/sample-apps/build-a-starter-website-using-nuxt3-and-contentstack/#import-content. In step 3 it is required to import the starter content. The command csdx cm:stacks:seed --repo "contentstack/stack-starter-app" results in the following error:

Creating Stack 'nuxt_starter' within Organization '[ORG NAME]'... !
    TypeError: Cannot read properties of undefined (reading 'data')

No other information is given.

Here are my versions:

$ node --version
v20.2.0
$ csdx --version
@contentstack/cli/1.7.5 darwin-x64 node-v20.2.0
macOS Ventura 13.4

First time install - need to set correct region before login

Hey,

I was following https://www.contentstack.com/docs/developers/cli/install-the-cli/ and with the latest 1.5.0 while trying to login, I got error message TypeError: Cannot read properties of undefined (reading 'cma').

Downgrading to 1.4.0 gave me login error No region found, please set a region $config:set:region and after setting that up and upgrading back to latest 1.5.0 the original error message went away.

Additionally I set my region first as EU (I'm in Europe) but login was flagged as incorrect - switching to NA region fixes the problem.

Below the commands -

Following https://www.contentstack.com/docs/developers/cli/install-the-cli/

% npm install -g @contentstack/cli

changed 583 packages in 4s

46 packages are looking for funding
  run `npm fund` for details
% csdx --version
@contentstack/cli/1.5.0 darwin-arm64 node-v20.0.0
% csdx auth:login 
    TypeError: Cannot read properties of undefined (reading 'cma')

Downgrading to 1.4.0 and getting region set msg.

% npm install -g @contentstack/[email protected]

removed 4 packages, and changed 579 packages in 4s

46 packages are looking for funding
  run `npm fund` for details
% csdx --version 

@contentstack/cli/1.4.0 darwin-arm64 node-v20.0.0
% 
% csdx auth:login 
No region found, please set a region $config:set:region
% csdx config:set:region EU
Region has been set to EU
CDA HOST: https://eu-cdn.contentstack.com
CMA HOST: https://eu-api.contentstack.com
% csdx auth:login          

 Currently using EU region 

? Enter your email address 

Upgrading back to 1.5.0 and can move to login.

% npm install -g @contentstack/cli

added 4 packages, and changed 579 packages in 22s

46 packages are looking for funding
  run `npm fund` for details
% csdx auth:login                 
? Enter your email address 

Login with regions

csdx auth:login

 Currently using EU region 

? Enter your email address ***
? Enter your password ***
Login Error
Looks like your email or password is invalid. Please try again or reset your password.
% csdx config:set:region NA
Region has been set to NA
CDA HOST: https://cdn.contentstack.io
CMA HOST: https://api.contentstack.io
% csdx auth:login          

 Currently using NA region 

? Enter your email address ***
? Enter your password ***
Successfully logged in!!

Not sure if these are bugs or workflow issues, but having better error messaging for end user (eg requiring correct region before trying to login) and https://www.contentstack.com/docs/developers/cli/install-the-cli/ reflecting these would be helpful ๐Ÿ˜„

Feature Request: Support clone across regions

We have a stack in a demo account in the US region that we'd like to move to the production stack in EU. Currently the clone command only support cloning in the same region. It would be helpful if you could set the region when cloning through the cli.

NextJs Bootstrap

When running the CLI command top bootstrap a nextjs application, the project produces an issue with running eslint. Specifically, the web vitals extension is not configured correctly in .eslint.json. When the adjustment is made locally, this then produces a lot of lint issues that blocks building the application.

I noticed this was fixed in the nextjs starter kit project (master branch), though the CLI still seems to build the project with a older revision (cli-use). It's been difficult to track this down int the CLI source code, though see it here: https://github.com/contentstack/cli/blob/f28b829d6c60dcd81db7675f37c90620b312034f/packages/contentstack-bootstrap/src/bootstrap/github/client.ts#L10C1-L11C1

Can cli-use branch be updated from master so the latest project is installed with bootstrap?

Unable to use the cli with SSO authentication

Hi there, after updating the CLI we're unable to use our management tokens to perform any updates, since it seems to now require email/password authentication to even add and manage tokens... Also after updating all my tokens were removed.
Why is there a requirement to log in via email / password to use the CLI? this makes it unusable for enterprise customers. Is there a plan to either add support for SSO or remove this limitation?

Exporting and importing problems

Situation: I cannot use the export and import tool to properly import new content (content types or entries).

problem - branch name nesting:

I export from my main stack:

npx csdx cm:stacks:export -k bltxxx -d "D:\wrk\contentstack\stackname" --module entries

The above creates folder structure like:

stackname
 - logs
 - main  <- this is the "branch"
   - content_types
   - entries
     - question
       - en-us
   - locales

Then when running the import command on the same folder

npx csdx cm:stacks:import -k bltxxx -d "D:\wrk\contentstack\stackname" --module entries

I get the following error message

error: Failed to import stack content - ENOENT: no such file or directory, scandir 'D:\wrk\contentstack\_backup_408\content_types'

This seems that the import process is not accounting for the main folder, which is the branch that we are exporting.

WORKAROUND: When I move the folders inside the stackname/main directory, to the root of stackname folder... then the import process proceeds without the error. This leads me to believe the branch name is missing from the importing process.

Note:

Even if I include the branch name in the arguments:

npx csdx cm:stacks:import -k bltxxx -d "D:\wrk\contentstack\stackname" --branch main --module entries

It tells me it is successful, but it never really goes through any process because it does not find the schema.json file inside the content-type folder. The output is:

Copying content to the backup directory...
info: Starting to import content version 2
info: Starting import of entries module
info: No content type found
info: The content has been imported to the stack bltxxxxxxxxx successfully!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.