Quellcode durchsuchen

docs: Update documentation for plugins & getting started

Michael Bromley vor 6 Jahren
Ursprung
Commit
50cf54e9f8

+ 30 - 80
docs/content/docs/getting-started.md

@@ -8,101 +8,51 @@ weight: 0
 ## Requirements
  
 * [Node.js](https://nodejs.org/en/) **v8.9.0** or above
-* An SQL database compatible with [TypeORM](http://typeorm.io/#/), i.e. MySQL, MariaDB, PostgreSQL, SQLite, Microsoft SQL Server, sql.js, Oracle.
+* If you want to use MySQL, MariaDB, or Postgres as your data store, then you'll need an instance available locally. However, if you are just testing out Vendure, we recommend using SQLite, which has no external requirements.
  
-## Installation
+## Installation with @vendure/create
 
-The following instructions describe how to run a development instance of Vendure using ts-node and SQLite.
-
-### Set up the database
-
-You'll need a database to store your shop data.
-
-{{% tab "SQLite" %}}
-The simplest way to try out Vendure is to use SQLite, since it does not require a separate database server to work. You only need to install the [sqlite3 driver](https://www.npmjs.com/package/sqlite3) to allow Vendure to read and write to an SQLite database file:
-```bash
-$ npm install sqlite3
-
-# or with Yarn
-$ yarn add sqlite3
+The recommended way to get started with Vendure is by using the [@vendure/create](https://github.com/vendure-ecommerce/vendure/tree/master/packages/create) tool. This is a command-line tool which will scaffold and configure your new Vendure project and install all dependiencies.
 
+{{% tab "npx" %}}
+```sh
+npx @vendure/create my-app
 ```
-{{% /tab %}}
-{{% tab "MySQL/MariaDB" %}}
-You'll need a MySQL or MariaDB server available to your local machine. For development we can recommend the [bitnami-docker-phpmyadmin](https://github.com/bitnami/bitnami-docker-phpmyadmin) Docker image, which is MariaDB including phpMyAdmin.
 
-In addition, you must install the [mysql driver](https://www.npmjs.com/package/mysql) for Node.js:
-```bash
-$ npm install mysql
-
-# or with Yarn
-$ yarn add mysql
-
-```
+{{% alert primary %}}
+[npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher.
+{{% /alert %}}
 {{% /tab %}}
-{{% tab "PostgreSQL" %}}
-You'll need a PostgreSQL server available to your local machine.
-
-In addition, you must install the [pg driver](https://www.npmjs.com/package/pg) for Node.js:
-```bash
-$ npm install pg
-
-# or with Yarn
-$ yarn add pg
-
+{{% tab "npm init" %}}
+```sh
+npm init @vendure my-app
 ```
+{{% alert primary %}}
+`npm init <initializer>` is available in npm 6+
+{{% /alert %}}
 {{% /tab %}}
-
-### Install ts-node
-
-**TypeScript only:** If you want to use TypeScript, [ts-node](https://www.npmjs.com/package/ts-node) allows you to run TypeScript directly without a compilation step, which is convenient for development.
-
-```bash
-$ npm install --save-dev ts-node
-
-# or with Yarn
-$ yarn add --dev ts-node 
-```
-
-### Install Vendure
-
-```bash
-$ npm install @vendure/core@alpha
-
-# or with Yarn
-$ yarn add @vendure/core@alpha
-```
-
-### Initialize with the Vendure CLI
-
-Vendure includes a CLI program which can generate the initial configuration and entry file for your server:
-
-```bash
-$ npx vendure init
-
-# or with Yarn
-$ yarn vendure init
+{{% tab "yarn create" %}}
+```sh
+yarn create @vendure my-app
 ```
+{{% alert primary %}}
+`yarn create` is available in Yarn 0.25+
+{{% /alert %}}
+{{% /tab %}}
 
-The init command will ask a series of questions which allow the CLI to generate a configuration and index file.
+*For other installation options see the [@vendure/create documentation](https://github.com/vendure-ecommerce/vendure/blob/master/packages/create/README.md).*
 
-### Run
 
-Once the init script has completed, the server can be started.
+"my-app" in the above command would be replaced by whatever you'd like to name your new project.
+Vendure Create will guide you through the setup. When done, you can run:
 
-{{% tab "TypeScript" %}}
-```bash
-$ npx ts-node index
+```sh
+cd my-app
 
-# or with Yarn
-$ yarn ts-node index
-```
-{{% /tab %}}
-{{% tab "JavaScript" %}}
-```bash
-$ node index
+yarn start
+# or
+npm run start
 ```
-{{% /tab %}}
 
 Assuming the default config settings, you can now access:
 

+ 4 - 0
docs/content/docs/plugins/default-search-plugin.md

@@ -6,7 +6,11 @@ title: "DefaultSearchPlugin"
 
 The DefaultSearchPlugin provides a full-text Product search based on the full-text searching capabilities of the underlying database.
 
+The DefaultSearchPlugin is bundled with the `@vendure/core` package. If you are not using an alternative search plugin, then make sure this one is used, otherwise you will not be able to search products via the [`search` query](/docs/graphql-api/shop/queries#search).
+
 ```ts
+import { DefaultSearchPlugin } from '@vendure/core';
+
 const config: VendureConfig = {
   // Add an instance of the plugin to the plugins array
   plugins: [

+ 3 - 1
docs/content/docs/plugins/writing-a-vendure-plugin.md

@@ -98,6 +98,7 @@ Now that we've defined the new mutation, we'll need a resolver function to handl
 ```ts 
 import { Args, Mutation, Resolver } from '@nestjs/graphql';
 import { Ctx, Allow, ProductService, RequestContext } from '@vendure/core';
+import { Permission } from '@vendure/common/lib/generated-types';
 
 @Resolver()
 export class RandomCatResolver {
@@ -212,7 +213,8 @@ import { Injectable } from '@nestjs/common';
 import { Args, Mutation, Resolver } from '@nestjs/graphql';
 import gql from 'graphql-tag';
 import http from 'http';
-import { Allow, Ctx, Permission, ProductService, RequestContext, VendureConfig, VendurePlugin } from '@vendure/core';
+import { Allow, Ctx, ProductService, RequestContext, VendureConfig, VendurePlugin } from '@vendure/core';
+import { Permission } from '@vendure/common/lib/generated-types';
 
 export class RandomCatPlugin implements VendurePlugin {
 

+ 10 - 0
packages/admin-ui-plugin/src/plugin.ts

@@ -51,8 +51,18 @@ export interface AdminUiOptions {
  *
  * The Admin UI allows you to administer all aspects of your store, from inventory management to order tracking. It is the tool used by store administrators on a day-to-day basis for the management of the store.
  *
+ * ## Installation
+ *
+ * `yarn add @vendure/admin-ui-plugin`
+ *
+ * or
+ *
+ * `npm install @vendure/admin-ui-plugin`
+ *
  * @example
  * ```ts
+ * import { AdminUiPlugin } from '@vendure/admin-ui-plugin';
+ *
  * const config: VendureConfig = {
  *   // Add an instance of the plugin to the plugins array
  *   plugins: [

+ 10 - 0
packages/asset-server-plugin/src/plugin.ts

@@ -94,8 +94,18 @@ export interface AssetServerOptions {
  * The `AssetServerPlugin` serves assets (images and other files) from the local file system. It can also perform on-the-fly image transformations
  * and caches the results for subsequent calls.
  *
+ * ## Installation
+ *
+ * `yarn add @vendure/asset-server-plugin`
+ *
+ * or
+ *
+ * `npm install @vendure/asset-server-plugin`
+ *
  * @example
  * ```ts
+ * import { AssetServerPlugin } from '@vendure/asset-server-plugin';
+ *
  * const config: VendureConfig = {
  *   // Add an instance of the plugin to the plugins array
  *   plugins: [

+ 18 - 0
packages/create/README.md

@@ -32,4 +32,22 @@ yarn create @vendure my-app
 
 *`yarn create` is available in Yarn 0.25+*
 
+
 It will create a directory called `my-app` inside the current folder.
+
+## Options
+
+### `--use-npm`
+
+By default, Vendure Create will attempt to use Yarn to install all dependencies if it is available. You can override this and force it to use npm with the `--use-npm` flag.
+
+### `--log-level`
+
+You can control how much output is generated during the installation and setup with this flag. Valid options are `silent`, `info` and `verbose`. The default is `silent`
+
+Example:
+
+```sh 
+npx @vendure/create my-app --log-level verbose
+```
+

+ 1 - 1
packages/create/src/create-vendure-app.ts

@@ -34,7 +34,7 @@ program
         projectName = name;
     })
     .option(
-        '-log-level <logLevel>',
+        '--log-level <logLevel>',
         'Log level, either \'silent\', \'info\', or \'verbose\'',
         /^(silent|info|verbose)$/i,
         'silent',

+ 1 - 1
packages/email-plugin/package.json

@@ -6,7 +6,7 @@
   "types": "lib/index.d.ts",
   "files": ["lib/**/*", "templates/**/*"],
   "scripts": {
-    "build": "rimraf dist && tsc -p ./tsconfig.build.json"
+    "build": "rimraf lib && tsc -p ./tsconfig.build.json"
   },
   "dependencies": {
     "dateformat": "^3.0.3",

+ 20 - 0
packages/email-plugin/src/plugin.ts

@@ -14,8 +14,18 @@ import { EmailOptions, EmailPluginDevModeOptions, EmailPluginOptions, EmailTrans
  * The EmailPlugin creates and sends transactional emails based on Vendure events. It uses an [MJML](https://mjml.io/)-based
  * email generator to generate the email body and [Nodemailer](https://nodemailer.com/about/) to send the emais.
  *
+ * ## Installation
+ *
+ * `yarn add @vendure/email-plugin`
+ *
+ * or
+ *
+ * `npm install @vendure/email-plugin`
+ *
  * @example
  * ```ts
+ * import { EmailPlugin } from '@vendure/email-plugin';
+ *
  * const config: VendureConfig = {
  *   // Add an instance of the plugin to the plugins array
  *   plugins: [
@@ -35,6 +45,16 @@ import { EmailOptions, EmailPluginDevModeOptions, EmailPluginOptions, EmailTrans
  * };
  * ```
  *
+ * ## Email templates
+ *
+ * In the example above, the plugin has been configured to look in `<app-root>/vendure/email/templates`
+ * for the email template files. If you used `@vendure/create` to create your application, the templates will have
+ * been copied to that location during setup.
+ *
+ * If you are installing the EmailPlugin separately, then you'll need to copy the templates manually from
+ * `node_modules/@vendure/email-plugin/templates` to a location of your choice, and then point the `templatePath` config
+ * property at that directory.
+ *
  * ## Customizing templates
  *
  * Emails are generated from templates which use [MJML](https://mjml.io/) syntax. MJML is an open-source HTML-like markup