mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 03:17:11 +00:00
commit
d05150e163
16
README.md
16
README.md
@ -44,6 +44,22 @@ You now are able to use the Strapi CLI. Simply create your first application and
|
||||
$ strapi new <appName>
|
||||
```
|
||||
|
||||
Note that you can generate a dry application using the `dry` option:
|
||||
|
||||
```bash
|
||||
$ strapi new <appName> --dry
|
||||
```
|
||||
|
||||
This will generate a Strapi application without:
|
||||
|
||||
- the built-in `user`, `email` and `upload` APIs,
|
||||
- the `grant` hook,
|
||||
- the open-source admin panel,
|
||||
- the Waterline ORM (`waterline` and `blueprints` hooks disabled),
|
||||
- the Strapi Studio connection (`studio` hook disabled).
|
||||
|
||||
This feature allows you to only use Strapi for your HTTP server structure if you want to.
|
||||
|
||||
### Start your application
|
||||
|
||||
```bash
|
||||
|
||||
@ -52,6 +52,13 @@ module.exports = function () {
|
||||
strapiPackageJSON: packageJSON
|
||||
};
|
||||
|
||||
// Save the `dry` option inside the scope.
|
||||
if (scope.args[1] && scope.args[1].dry) {
|
||||
scope.dry = true;
|
||||
} else {
|
||||
scope.dry = false;
|
||||
}
|
||||
|
||||
// Pass the original CLI arguments down to the generator
|
||||
// (but first, remove commander's extra argument)
|
||||
cliArguments.pop();
|
||||
|
||||
@ -44,6 +44,7 @@ cmd = program.command('new');
|
||||
cmd.unknownOption = NOOP;
|
||||
cmd.description('create a new application ');
|
||||
cmd.action(require('./strapi-new'));
|
||||
cmd.option('-d, --dry', 'naked Strapi application');
|
||||
|
||||
// `$ strapi start`
|
||||
cmd = program.command('start');
|
||||
|
||||
@ -36,6 +36,17 @@ function Strapi() {
|
||||
// Mixin support for `Strapi.prototype.after()`.
|
||||
mixinAfter(this);
|
||||
|
||||
// Bind `this` context for all `Strapi.prototype.*` methods.
|
||||
this.load = this.load.bind(this);
|
||||
this.start = this.start.bind(this);
|
||||
this.stop = this.stop.bind(this);
|
||||
this.restart = this.restart.bind(this);
|
||||
this.initialize = this.initialize.bind(this);
|
||||
this.exposeGlobals = this.exposeGlobals.bind(this);
|
||||
this.runBootstrap = this.runBootstrap.bind(this);
|
||||
this.isLocalStrapiValid = this.isLocalStrapiValid.bind(this);
|
||||
this.isStrapiAppSync = this.isStrapiAppSync.bind(this);
|
||||
|
||||
// Expose `koa`.
|
||||
this.server = require('koa');
|
||||
this.app = require('koa')();
|
||||
|
||||
@ -116,8 +116,10 @@ module.exports = function (strapi) {
|
||||
// (aiming to not have issue with adapters when rebuilding the dictionary).
|
||||
// It's kind of messy, for now, but it works fine. If someone has a better
|
||||
// solution we'd be glad to accept a Pull Request.
|
||||
const ormConfig = JSON.parse(fs.readFileSync(path.resolve(strapi.config.appPath, strapi.config.paths.config, 'environments', strapi.config.environment, 'databases.json')));
|
||||
strapi.config.orm = ormConfig.orm;
|
||||
if (!strapi.config.dry) {
|
||||
const ormConfig = JSON.parse(fs.readFileSync(path.resolve(strapi.config.appPath, strapi.config.paths.config, 'environments', strapi.config.environment, 'databases.json')));
|
||||
strapi.config.orm = ormConfig.orm;
|
||||
}
|
||||
|
||||
// Save different environments inside an array because we need it in the Strapi Studio.
|
||||
strapi.config.environments = fs.readdirSync(path.resolve(strapi.config.appPath, strapi.config.paths.config, 'environments'));
|
||||
|
||||
@ -64,6 +64,9 @@ module.exports = function (strapi) {
|
||||
workers: os.cpus().length
|
||||
},
|
||||
|
||||
// Application is not `dry` by default.
|
||||
dry: false,
|
||||
|
||||
// Default paths.
|
||||
paths: {
|
||||
tmp: '.tmp',
|
||||
|
||||
@ -37,7 +37,16 @@ module.exports = function (strapi) {
|
||||
delete hooks.studio;
|
||||
}
|
||||
|
||||
// Handle folder-defined modules (default to `lib/index.js`)
|
||||
// Remove undesired hooks when this is a `dry` application.
|
||||
if (strapi.config.dry) {
|
||||
delete hooks.blueprints;
|
||||
delete hooks.dashboard;
|
||||
delete hooks.grant;
|
||||
delete hooks.studio;
|
||||
delete hooks.waterline;
|
||||
}
|
||||
|
||||
// Handle folder-defined modules (default to `./lib/index.js`)
|
||||
// Since a hook definition must be a function.
|
||||
if (_.isObject(hookPrototype) && !_.isArray(hookPrototype) && !_.isFunction(hookPrototype)) {
|
||||
hookPrototype = hookPrototype.index;
|
||||
|
||||
@ -12,6 +12,13 @@ const Strapi = require('./Strapi');
|
||||
* (maintains backwards compatibility with constructor usage).
|
||||
*/
|
||||
|
||||
module.exports = function () {
|
||||
module.exports = strapiFactory;
|
||||
|
||||
function strapiFactory() {
|
||||
return new Strapi();
|
||||
};
|
||||
}
|
||||
|
||||
// Backwards compatibility for Strapi singleton usage.
|
||||
const singleton = strapiFactory();
|
||||
strapiFactory.isLocalStrapiValid = singleton.isLocalStrapiValid.bind(singleton);
|
||||
strapiFactory.isStrapiAppSync = singleton.isStrapiAppSync.bind(singleton);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user