Home Reference Source Repository

Function

Static Public Summary
public

Adds a trailing slashes to a path.

public

clean(path: string): Promise

Cleans a directory

public

createBuilder(target: string, rocBuilder: rocBuilder, resolver: string): rocBuilder

Creates a builder.

public

createServer(options: rocServerOptions, beforeUserMiddlewares: Function[]): rocServer

Creates a server instance.

public

getBuilder(debug: boolean, target: string, createBuilders: function | array | object, extensionCreateBuilders: object | array): rocBuilder

Gets the final rocBuilder object..

public

getDevPath(relativeBuildPath: string): string

Returns the current dev path.

public

Returns the current dev port.

public

Returns the current port.

public

getResolvePath(resolvePaths: ...string): string

Used on the server to find all dependecies.

public

listSettings(rocCommandObject: object)

List the settings that are possible with the current extensions.

public

markdownSettings(rocCommandObject: object)

List the settings that are possible with the current extensions in a markdown format.

public

middlewares(config: object): array

Returns the middlewares to be used

public

Removes possible trailing slashes from a path.

public

runBuild(rocCommandObject: object): Promise

Build runner.

public

runDev(rocCommandObject: object)

Development runner.

public

start(rocCommandObject: object)

Starts a Roc application.

public

watchClient(compiler: object): Promise

Client watcher.

public

watchServer(compiler: object): Promise

Server watcher.

Static Public

public addTrailingSlash(path: string): string source

import {addTrailingSlash} from 'roc-web/lib/helpers/general.js'

Adds a trailing slashes to a path.

Runs removeTrailingSlash internally first.

Params:

NameTypeAttributeDescription
path string

Path to add a trailing slashes to.

Return:

string

Path with trailing slash.

public clean(path: string): Promise source

Cleans a directory

Params:

NameTypeAttributeDescription
path string

A directory that should be cleaned

Return:

Promise

A promise that either resolves when done or rejects if there is an error

public createBuilder(target: string, rocBuilder: rocBuilder, resolver: string): rocBuilder source

import createBuilder from 'roc-web/lib/builder/index.js'

Creates a builder.

Params:

NameTypeAttributeDescription
target string
  • nullable: false

a target: should be either "client" or "server"

rocBuilder rocBuilder

A rocBuilder to base everything on.

resolver string
  • optional
  • default: roc-web/lib/helpers/get-resolve-path
  • nullable: false

Path to the resolver for the server side getResolvePath

Return:

rocBuilder

public createServer(options: rocServerOptions, beforeUserMiddlewares: Function[]): rocServer source

import createServer from 'roc-web/src/app/server/index.js'

Creates a server instance.

Params:

NameTypeAttributeDescription
options rocServerOptions

Options for the server. Will override configuration in roc.config.js.

beforeUserMiddlewares Function[]

Middlewares that should be added before the user middlewares.

Return:

rocServer

server - Roc server instace.

Example:

import { createServer } from 'roc-web/app';

const server = createServer({
   serve: 'static',
   favicon: 'static/favicon.png'
});

server.start();

public getBuilder(debug: boolean, target: string, createBuilders: function | array | object, extensionCreateBuilders: object | array): rocBuilder source

import {getBuilder} from 'roc-web/lib/helpers/plugin-managment.js'

Gets the final rocBuilder object..

Params:

NameTypeAttributeDescription
debug boolean

If the command should run in debug mode

target string

What target the builder should be configured against

createBuilders function | array | object

The createBuilders defined in the configuration. See documentation for more information on what it can be.

extensionCreateBuilders object | array

The createBuilders defined in the extensions. Should most often be an object.

Return:

rocBuilder

public getDevPath(relativeBuildPath: string): string source

import {getDevPath} from 'roc-web/lib/helpers/general.js'

Returns the current dev path.

Will use getDevPort for getting the port.

Params:

NameTypeAttributeDescription
relativeBuildPath string
  • optional

Relative path to where the build is saved.

Return:

string

The complete dev path on the server including the port.

public getDevPort(): number source

import {getDevPort} from 'roc-web/lib/helpers/general.js'

Returns the current dev port.

It will first default to the environment variable DEV_PORT and after that roc.config.js.

Will give a warning if DEV_PORT is defined and the value in the configuration is something other than default.

Return:

number

The final port for the dev server.

public getPort(): number source

import {getPort} from 'roc-web/lib/helpers/general.js'

Returns the current port.

It will first default to the environment variable PORT and after that roc.config.js.

Will give a warning if PORT is defined and the value in the configuration is something other than default.

Return:

number

The final port for the server.

public getResolvePath(resolvePaths: ...string): string source

import getResolvePath from 'roc-web/lib/helpers/get-resolve-path.js'

Used on the server to find all dependecies.

When creating a extension of this project this needs to be extended.

Params:

NameTypeAttributeDescription
resolvePaths ...string

Paths to be resolved.

Return:

string

Path that can be used with Module._initPaths().

Example:

import path from 'path';
import { getResolvePath } from 'roc-web';

export default function(...resolvePaths) {
    return getResolvePath(path.join(__dirname, '..', 'node_modules'), ...resolvePaths);
}

public listSettings(rocCommandObject: object) source

import {listSettings} from 'roc-web/lib/commands/index.js'

List the settings that are possible with the current extensions.

Params:

NameTypeAttributeDescription
rocCommandObject object

A command object

public markdownSettings(rocCommandObject: object) source

import {markdownSettings} from 'roc-web/lib/commands/index.js'

List the settings that are possible with the current extensions in a markdown format.

Params:

NameTypeAttributeDescription
rocCommandObject object

A command object

public middlewares(config: object): array source

import middlewares from 'roc-web/src/app/server/middlewares.js'

Returns the middlewares to be used

Params:

NameTypeAttributeDescription
config object

A roc config object.

Return:

array

A array with middlewares to use.

public removeTrailingSlash(path: string): string source

import {removeTrailingSlash} from 'roc-web/lib/helpers/general.js'

Removes possible trailing slashes from a path.

Params:

NameTypeAttributeDescription
path string

Path to remove possible trailing slashes.

Return:

string

Path without trailing slashes.

public runBuild(rocCommandObject: object): Promise source

import runBuild from 'roc-web/lib/commands/build.js'

Build runner.

Helper for building an application.

Params:

NameTypeAttributeDescription
rocCommandObject object

A command object

Return:

Promise

A promise that will be resolved when the build is completed

public runDev(rocCommandObject: object) source

import runDev from 'roc-web/lib/commands/dev.js'

Development runner.

Helper for starting an application in watch mode.

Params:

NameTypeAttributeDescription
rocCommandObject object

A command object

public start(rocCommandObject: object) source

import start from 'roc-web/lib/commands/start.js'

Starts a Roc application.

Params:

NameTypeAttributeDescription
rocCommandObject object

A command object

public watchClient(compiler: object): Promise source

import watchClient from 'roc-web/lib/runtime/watch-client.js'

Client watcher.

Params:

NameTypeAttributeDescription
compiler object

Webpack compiler instance.

Return:

Promise

Resolves after it has completed.

public watchServer(compiler: object): Promise source

import watchServer from 'roc-web/lib/runtime/watch-server.js'

Server watcher.

Params:

NameTypeAttributeDescription
compiler object

a Webpack compiler instance

Return:

Promise

Resolves after it has completed.