sails new创建一个新的 Sails 项目。
sails new your-app-name
大多数 Sails 应用程序只需运行 sails new your-app-name 即可生成,无需任何额外定制。但 sails new 也接受以下选项
--no-frontend: 当生成一个不会用于服务任何前端资源的 Sails 应用程序时很有用。禁用 assets/ 文件夹、tasks/ 文件夹和相关文件的生成。--minimal: 生成一个极其简化的 Sails 应用程序。这会禁用与 --no-frontend 相同的内容,以及 i18n、Waterline、Grunt、Lodash、Async、会话和视图。--without: 用于生成一个没有指定功能的 Sails 应用程序。支持的“without”选项包括:'lodash'、'async'、'orm'、'sockets'、'grunt'、'i18n'、'session' 和 'views'。要一次禁用多个功能,您可以将选项包含在逗号分隔的列表中,例如 sails new your-app-name --without=grunt,views。要在 code/testProject/ 中创建一个名为“test-project”的项目
$ sails new code/testProject
info: Installing dependencies...
Press CTRL+C to skip.
(but if you do that, you'll need to cd in and run `npm install`)
info: Created a new Sails app `test-project`!
在现有的 myProject/ 文件夹中创建一个 Sails 项目
$ cd myProject
$ sails new .
info: Installing dependencies...
Press CTRL+C to skip.
(but if you do that, you'll need to cd in and run `npm install`)
info: Created a new Sails app `my-project`!
在现有文件夹中创建新的 Sails 应用程序只有在文件夹为空时才有效。
sails new实际上只是一个特殊的 生成器,它运行sails-generate-new。换句话说,运行sails new foo等同于运行sails generate new foo,并且像任何 Sails 生成器一样,实际运行的生成器模块可以在您的全局~/.sailsrc文件中被覆盖。