Giter VIP home page Giter VIP logo

apostrophe-cli's Introduction

Apostrophe CLI

⚠️ NOTE: apostrophe-cli is a deprecated version of the ApostropheCMS command line tool. Please use @apostrophecms/cli instead. ⚠️

The Apostrophe CLI is a cross-platform starting point for creating and configuring ApostropheCMS projects, providing a simple boilerplate generator and wrapping other useful functions into an easy to use command line tool.

Requires Node.js 8+

First, install apostrophe-cli as a global NPM module:

npm install -g apostrophe-cli

To view the available commands in a given context, execute the newly-installed command with no arguments:

apos

Note: All Apostrophe CLI commands can also be run with apostrophe, the legacy command, in addition to apos.

Create a project

To create a new project with the tool:

apos create-project <shortname-without-spaces>

This will create a local copy of our standard Apostrophe Boilerplate.

options

Run create-project with a --boilerplate flag to start from a Github repository other than the standard apostrophe-boilerplate repo. For example, apos create-project <shortname-without-spaces> --boilerplate=https://github.com/apostrophecms/apostrophe-open-museum.git would create a project using the Open Museum demo.

If you run the create-project command with the --setup flag, the command will also npm install the dependencies for the project and run apostrophe-users:add to create an admin user for the CMS, resulting in a fully bootstrapped project. This command will prompt you for a password for the admin user being created.

Create a widget

To bootstrap the necessary files and basic configuration for a new Apostrophe widget, run the following command from within your Apostrophe project's root directory:

# "-widgets" will automatically be appended to the end of your module name
apos create-widget fancy-button

Note: You will then need to register this widget module in app.js so it is available in your project code. The same is true for the commands below when you create a piece module or generic module.

// app.js
module.exports = {
  // ...
  'fancy-button-widgets': {},
  // ...
}

Create a piece

To bootstrap the necessary files and basic configuration for a new Apostrophe piece type, run the following command from within your Apostrophe project's root directory:

# be sure to use the SINGULAR version of the name of your content type
apos create-piece vegetable

Then remember to register 'vegetables': {} in apps.js above.

If you run the create-piece command with the --pages flag, the command will also set up a corresponding pieces-pages module with your new piece type. Similarly, you can run the create-piece command with the --widgets flag, which will also set up a corresponding pieces-widgets module along with your new piece type. These flags can be used together or separately.

apos create-piece vegetable --pages --widgets

Create an empty Apostrophe module

To bootstrap the necessary files and basic configuration for a brand-new Apostrophe module that doesn't extend one of the usual suspects like pieces or widgets:

apos create-module <module name>

Remember to register the module in apps.js with the other module types.

Run other Apostrophe-flavored command-line tasks

To run an Apostrophe command-line task with the Apostrophe CLI, which are conventionally run like this: node app.js <namespace>:<task name>, you may instead execute the following from any location within a project's directory:

apos <namespace>:<task name>

The Apostrophe CLI assumes the apostrophe namespace when executing tasks. This means that if a task is in the apostrophe namespace (such as the apostrophe:generation task), you can simply execute:

apos <task name>

For more information on command-line tasks in Apostrophe, visit the Command line tasks documentation for Apostrophe.


For more documentation for ApostropheCMS, visit the documentation site.

apostrophe-cli's People

Contributors

abea avatar bgantick avatar boutell avatar dependabot[bot] avatar jsumnersmith avatar jth- avatar kylestetz avatar madarche avatar

Stargazers

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

Watchers

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

apostrophe-cli's Issues

Error: connect ECONNREFUSED 151.101.0.133:443

I am new to this and I just follow the step to install all the programs, and while I try

apostrophe create-project test-project

It result error

/usr/local/lib/node_modules/apostrophe-cli/node_modules/sync-rpc/lib/index.js:167
throw error;
^

Error: connect ECONNREFUSED 151.101.0.133:443

Do I did something wrong? How can I fix this?

Process crashes if there is a missing dependency

Note that currently the only dependency is Git.

/usr/lib/node_modules/apostrophe-cli/lib/util.js:33
  console.log(dep + ' not found'.red);
              ^
ReferenceError: dep is not defined
    at Object.util.missingDependency (/usr/lib/node_modules/apostrophe-cli/lib/util.js:33:15)
    at Object.util.checkDependencies (/usr/lib/node_modules/apostrophe-cli/lib/util.js:43:12)
    at Object.<anonymous> (/usr/lib/node_modules/apostrophe-cli/bin/apostrophe:10:6)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:929:3

mistyped command throws confusing error

I accidentally tried to run new-project PROJECT instead of create-project PROJECT and got this misleading error

❯ apostrophe new-project hi

Apostrophe  new-project  Running the task [1/1]
Apostrophe  Unable to locate an app.js in this directory. You need to be in the root directory of an Apostrophe project to run this command.  Failed 

Not sure this is the default error or what but it should at least error out telling you to look at -help for options

Dependency (winston) breaks on node 14.x

Winston 2.x doesn't work with node 14.x. and thus breaks this tool.

winstonjs/winston#1797

 Apostrophe  create-project  Failed
(node:75963) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
    at emitCircularRequireWarning (internal/modules/cjs/loader.js:823:11)
    at Object.get (internal/modules/cjs/loader.js:837:5)
    at Object.exports.setLevels (/Users/kyron/.nvm/versions/node/v14.4.0/lib/node_modules/apostrophe-cli/node_modules/winston/lib/winston/common.js:32:14)
    at Object.<anonymous> (/Users/kyron/.nvm/versions/node/v14.4.0/lib/node_modules/apostrophe-cli/node_modules/winston/lib/winston.js:83:8)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)

For now I've downgraded my node version to 13.x and it's working fine.

Truncated error

alex@RainbowStar:~/Projects/new-project$ apostrophe create-piece

  error: missing required argument `piec'

Not sure why it doesn't say piece. A quick search through the code shows no results for piec. Wondering if this is being truncated, maybe by shelljs.

Very minor issue, but confusing nontheless.

apostrophe create-piece overwrites existing files if they already exist without warning

When running create-piece the CLI just overwrites existing files without warning. It seems like a warning here would be a reasonable poke yoke, to prevent a user from potentially losing work.

I haven't checked to see if this is true about the other CLI create commands, but it probably is, and again a warning poke yoke on these would be helpful.

Squash danger vibes

The use of red for the log responses triggers error responses in developers (me). I'd suggest using blue or magenta maybe?

apostrophe 2.1.1

I think via npm install apostrophe-cli -g, I should get apostrophe 2.1.2 if I use a command of "apostrophe --version" to check. do I make sense?

apostrophe-users:add does not work via cli tool

I know the cli is not the recommended way to running apostrophe tasks, but since it's a documented feature I thought I would log this issue. I tried to run apostrophe apostrophe-users:add admin admin during my project set up, but got an error. It worked when running node app.js ...

$ apos apostrophe-users:add admin admin
 
 Apostrophe  apostrophe-users:add  Running the task [1/1]
WARNING: No session secret provided, please set the `secret` property of the `session` property of the apostrophe-express module in app.js
Incorrect number of arguments.
 
 Apostrophe  apostrophe-users:add  Failed

$ node app.js apostrophe-users:add admin admin
WARNING: No session secret provided, please set the `secret` property of the `session` property of the apostrophe-express module in app.js
prompt: password:  

error creating apos-app (apos create apos-app)

Running apos create apos-app throws this error:

Apostrophe  Unable to locate an app.js in this directory. You need to be in the root directory of an Apostrophe project to run this command.  Failed
(node:17960) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)

Running apos create-project apos-app throws this error:

 Apostrophe  create-project  Grabbing the boilerplate from Github [1/2]
Cloning into 'apos-app'...

 Apostrophe  create-project  Setting up your project shortname [2/2]
(node:13660) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)

image

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.