Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

strider-extension-loader

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strider-extension-loader - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

LICENSE

23

main.js

@@ -83,2 +83,3 @@ //

function(err, striderData, packageData) {
console.log("Loading module: ", moduleDir);
if (err) {

@@ -110,2 +111,6 @@ return cb(err, null);

}
if (extensionConfig.templates){
console.log("---> Loading Plugin Templates")
extension.templates = extensionConfig.templates;
}
cb(null, extension);

@@ -134,2 +139,4 @@ }

function initExtensions(extdir, type, context, appInstance, cb) {
var templates = {}
Step(

@@ -154,3 +161,4 @@ function() {

}
var initCount = 0;
var initCount = 0
// now to initialize

@@ -162,3 +170,3 @@ var self = this;

var l = loaded[i];
if (l.ext === null || !l.ext[type]) {
if (l.ext === null) {
continue;

@@ -205,2 +213,11 @@ }

}
if (l.ext.templates){
for (var k in l.ext.templates){
templates[k] = l.ext.templates[k]
if (/\.html/.test(l.ext.templates[k])){
templates[k] = l.dir + '/' + l.ext.templates[k];
}
}
}
}

@@ -217,3 +234,3 @@ if (initCount === 0) {

}
cb(null, initialized);
cb(null, initialized, templates);
}

@@ -220,0 +237,0 @@ );

2

package.json
{
"name": "strider-extension-loader",
"version": "0.1.0",
"version": "0.1.1",
"description": "Load Strider extensions",

@@ -5,0 +5,0 @@ "main": "main.js",

@@ -1,9 +0,130 @@

### Strider Extension Loader
# Strider Extension Loader
This is a small Node.JS library for loading Strider extensions. Strider
extensions are simply NPM packages with additional metadata contained in a file
named "strider.json". This metadata tells Strider which JavaScript source files
should be loaded and initialized to extend the web application server and
worker process respectively.
[Strider](https://github.com/Strider-CD/strider) is an extensible CI system, written
in node. Strider extensions are simply NPM packages with additional metadata contained
in a file named `strider.json`. This metadata tells Strider which JavaScript source files
should be loaded and initialized.
Hence, to install a new Strider extension, you can just `npm install` it.
Hence, to install a new Strider extension, you can just `npm install` it in your strider
repositiory.
This is a small Node.JS library for loading Strider extensions.
## Strider Extensions
There are several types of Strider extensions, namely:
### Workers
Strider workers are extensions that tell Strider how to execute tests or deploys. Some
good examples of Strider worker extensions are:
- [Custom Worker](https://github.com/Strider-CD/strider-custom)
- [Go Strider](https://github.com/Strider-CD/go-strider)
- [Simple Worker](https://github.com/Strider-CD/strider-simple-worker)
Strider worker extensions specify a `worker` in their `strider.json` - this is a node
module that exposes a function that Strider will call with a context:
```javascript
module.exports = function(ctx, cb){
...
}
```
The most common thing that you will want to do in that function, is to specify how
to test and deploy certain types of file - this is done with a method called
`addDetectionRule` :
```javascript
ctx.addDetectionRule({
filename: "**.foo", exists: true // If the repo contains a file with a foo extension
, language: "FooBar"
, framework: "Foo"
, prepare: "make foo"
, test: "foo test"
})
```
### Webapps
Another type of extension adds endpoints and content to Strider.
This is achieved with a webapp module specified in strider.json which exposes a function
as follows:
```javascript
module.exports = function(ctx, cb) {
// Add routes to strider:
ctx.routes.get("/foo/bar", function(req, res, next){
// This is an express3 route
})
// you can use authentication middleware and param validation:
ctx.routes.post("foo/bar"
, ctx.middleware.require_auth
, ctx.middleware.require_params(["url"])
, function(req, res, next){
res.send("Hi", req.currentUser.user.email)
})
// you can register 'blocks' to be inserted at
// specific points in existing pages. Any element with a class
// with the 'StriderBlock_' prefix can be specified here:
ctx.registerBlock('HeaderBrand', function(context){
// context has a lot of useful stuff on it:
var email = context.currentUser.user.email
return "<h1>FooStrider</h1>");
})
// [Note] ctx.registerPanel as seen in the sauce webapp is a legacy method
// that will eventually disappear and should be rewritten as:
// ctx.registerBlock("ProjectConfigPanel", foo)
cb(null) // No errors in extension
}
```
#### Templates
Because writing a bunch of `registerBlock` calls for simple pieces of template
overrides is a little tedious, you can also use the following shortcut in your
strider.json:
```javascript
{"templates": {
"HeaderBrand" : "<h1>An HTML String</h1>"
, "FooterTOS" : "./path/to/TOS.html"
}
}
```
These are either inline strings or paths to static HTML. There is no templating
available for these at present.
*Note* If more than one override is specified for a block, then the first one
will be used. At the moment this means that extensions can squash each other.
If you want to simply 'append' to a block, use the `registerBlock` method
and make sure that you prefix the html you return with:
`ctx.content` which will contain either the default html, or the content from
previous extensions.
#### Static Files
If you have additional static files, you can create a `static` directory in
your extension. These files will be available at `/ext/$modulename/...`
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc