Skip to content

Commit

Permalink
ZAPI-662: Initial repo setup
Browse files Browse the repository at this point in the history
  • Loading branch information
richardkiene committed Oct 7, 2015
0 parents commit 69a3902
Show file tree
Hide file tree
Showing 28 changed files with 3,301 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
@@ -0,0 +1,9 @@
/node_modules
/tmp
build
docs/*.json
docs/*.html
cscope.in.out
cscope.po.out
cscope.out
smf/manifests/bapi.xml
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "deps/jsstyle"]
path = deps/jsstyle
url = https://github.com/davepacheco/jsstyle.git
373 changes: 373 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions Makefile
@@ -0,0 +1,81 @@
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

#
# Copyright (c) 2014, Joyent, Inc.
#

#
# Makefile: basic Makefile for template API service
#
# This Makefile is a template for new repos. It contains only repo-specific
# logic and uses included makefiles to supply common targets (javascriptlint,
# jsstyle, restdown, etc.), which are used by other repos as well. You may well
# need to rewrite most of this file, but you shouldn't need to touch the
# included makefiles.
#
# If you find yourself adding support for new targets that could be useful for
# other projects too, you should add these to the original versions of the
# included Makefiles (in eng.git) so that other teams can use them too.
#

#
# Tools
#
TAP := ./node_modules/.bin/tap

#
# Files
#
DOC_FILES = index.md boilerplateapi.md
JS_FILES := $(shell ls *.js) $(shell find lib test -name '*.js')
JSON_FILES = package.json
JSL_CONF_NODE = tools/jsl.node.conf
JSL_FILES_NODE = $(JS_FILES)
JSSTYLE_FILES = $(JS_FILES)
JSSTYLE_FLAGS = -f tools/jsstyle.conf
REPO_MODULES = src/node-dummy
SMF_MANIFESTS_IN = smf/manifests/bapi.xml.in

NODE_PREBUILT_VERSION=v0.8.28

ifeq ($(shell uname -s),SunOS)
NODE_PREBUILT_CC_VERSION=4.6.2
NODE_PREBUILT_TAG=zone
endif

include ./tools/mk/Makefile.defs
ifeq ($(shell uname -s),SunOS)
include ./tools/mk/Makefile.node_prebuilt.defs
else
include ./tools/mk/Makefile.node.defs
endif
include ./tools/mk/Makefile.smf.defs

#
# Repo-specific targets
#
.PHONY: all
all: $(SMF_MANIFESTS) | $(TAP) $(REPO_DEPS)
$(NPM) rebuild

$(TAP): | $(NPM_EXEC)
$(NPM) install

CLEAN_FILES += $(TAP) ./node_modules/tap

.PHONY: test
test: $(TAP)
TAP=1 $(TAP) test/*.test.js

include ./tools/mk/Makefile.deps
ifeq ($(shell uname -s),SunOS)
include ./tools/mk/Makefile.node_prebuilt.targ
else
include ./tools/mk/Makefile.node.targ
endif
include ./tools/mk/Makefile.smf.targ
include ./tools/mk/Makefile.targ
60 changes: 60 additions & 0 deletions README.md
@@ -0,0 +1,60 @@
<!--
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->

<!--
Copyright (c) 2015, Joyent, Inc.
-->

# node-sdc-changefeed

Provides support for publishing and listening to change feeds in SmartDataCenter
/ Triton via Node.js libraries and a CLI.


## Installation

```
$ npm install node-sdc-changefeed # use -g if you'd like the CLI portion
```


## Development

Before committing be sure to, at least run:

```
$ make check # lint and style checks
$ make test # run tests
```


## Test

Simple tests can be run using:

```
$ make test
```

If you'd like to integration test against CoaL:

```
$ make test-integration-in-coal
```


## Documentation

[Detailed documentation is located at docs/index.md](docs/index.md).

See [RFD 0005 Triton Change Feed Support](https://github.com/joyent/rfd/blob/master/rfd/0005/README.md)
for current design and architecture decisions.

## License

"node-sdc-changefeed" is licensed under the
[Mozilla Public License version 2.0](http://mozilla.org/MPL/2.0/).
See the file LICENSE.
1 change: 1 addition & 0 deletions deps/jsstyle
Submodule jsstyle added at 194dde
17 changes: 17 additions & 0 deletions docs/index.md
@@ -0,0 +1,17 @@
---
title: node-sdc-changefeed documentation
markdown2extras: tables, code-friendly
apisections:
---
<!--
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->

<!--
Copyright (c) 2015, Joyent, Inc.
-->

Please see [Joyent Engineering Guidelines](https://github.com/joyent/eng/blob/master/docs/index.md)
for a general set of guidelines that apply to all Joyent repositories.
15 changes: 15 additions & 0 deletions lib/index.js
@@ -0,0 +1,15 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

/*
* Copyright (c) 2014, Joyent, Inc.
*/

/*
* A brief overview of this source file: what is its purpose.
*/

// TODO: put stuff here
21 changes: 21 additions & 0 deletions package.json
@@ -0,0 +1,21 @@
{
"name": "node-sdc-changefeed",
"description": "SmartDataCenter Change Feed Modules",
"version": "1.0.0",
"author": "Joyent (joyent.com)",
"private": true,
"dependencies": {
"restify": "2.2.1",
"node-uuid": "1.4.0",
"filed": "0.0.5",
"bunyan": "0.18.2"
},
"devDependencies": {
"tap": "0.4.0"
},
"scripts": {
"start": "node ./server.js",
"test": "./node_modules/.bin/tap test/*.test.js"
},
"license": "MPL-2.0"
}
19 changes: 19 additions & 0 deletions test/api.test.js
@@ -0,0 +1,19 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

/*
* Copyright (c) 2014, Joyent, Inc.
*/

/* Test the Boilerplate API endpoints */

var test = require('tap').test;


test('douglas adams', function (t) {
t.ok(42, 'the answer to life the universe and everything');
t.end();
});
164 changes: 164 additions & 0 deletions tools/bashstyle
@@ -0,0 +1,164 @@
#!/usr/bin/env node
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

/*
* Copyright (c) 2014, Joyent, Inc.
*/

/*
* bashstyle: check bash scripts for adherence to style guidelines, including:
*
* o no lines longer than 80 characters
* o file does not end with a blank line
* o Do not use 'local' and var initialization *using a subshell* in the
* same statement. See
* <http://www.tldp.org/LDP/abs/html/localvar.html#EXITVALANOMALY01>
* for why not. Arguably this belongs in a separate 'bashlint'.
*
* Future enhancements could include:
* o indents consistent with respect to tabs, spaces
* o indents consistently sized (all are some multiple of the smallest
* indent, which must be a tab or 4 or 8 spaces)
*/

var VERSION = '2.0.0';

var mod_assert = require('assert');
var mod_fs = require('fs');

var nerrors = 0;

main();
process.exit(0);

function main()
{
var files = process.argv.slice(2);

if (files.length === 0) {
console.error('usage: %s file1 [...]',
process.argv.slice(0, 2).join(' '));
process.exit(2);
}

files.forEach(checkFile);

if (nerrors != 0)
process.exit(1);
}

function checkFile(filename)
{
var text = mod_fs.readFileSync(filename, 'utf-8');
var lines = text.split('\n');
var i;
var styled = false;
var styleStart;

mod_assert.ok(lines.length > 0);

/*
* Expand tabs in each line and check for long lines.
*/
for (i = 1; i <= lines.length; i++) {
var line = expandTabs(lines[i - 1]);

if (i > 1 && lines[i-2].match(/# BASHSTYLED/)) {
continue;
}

if (line.match(/# BEGIN BASHSTYLED/)) {
styleStart = i;
styled = true;
}

if (line.match(/# END BASHSTYLED/)) {
if (styled != true) {
nerrors++;
console.log('%s: %d: END BASHSTYLED w/o corresponding BEGIN',
filename, i);
}
styled = false;
}

if (!styled && line.match(/^\s*local\s+(\w+)\s*=.*\$\(/)) {
nerrors++;
var m = line.match(/^\s*local\s+(\w+)\s*=/);
console.log('%s: %d: declaring and setting a "local" ' +
'var in the same statement ' +
'ignores a subshell return code ' +
'<http://www.tldp.org/LDP/abs/html/localvar.html#EXITVALANOMALY01>: ' +
'local %s=...',
filename, i, m[1]);
}

// Regexplanation: non-[, [, space (contents) space, ], non-]
// groups before and after brackets to ease search/replace.
if (!styled && line.match(/(^|[^\[])\[(\s.+\s)\]([^\]])/)) {
nerrors++;
console.log('%s: %d: prefer [[ to [ for tests.', filename, i);
}

if (!styled && line.length > 80) {
nerrors++;
console.log('%s: %d: line exceeds 80 columns',
filename, i);
}
}

if (styled) {
nerrors++;
console.log('%s: %d: BEGIN BASHSTYLED that does not END',
filename, styleStart);
}


/*
* No sane editor lets you save a file without a newline at the very end.
*/
if (lines[lines.length - 1].length !== 0) {
nerrors++;
console.log('%s: %d: file does not end with newline',
filename, lines.length);
}

/*
* Since the file will always end with a newline, the last entry of
* "lines" will actually be blank.
*/
if (lines.length > 1 && lines[lines.length - 2].length === 0) {
nerrors++;
console.log('%s: %d: file ends with a blank line',
filename, lines.length - 1);
}
}

function expandTabs(text)
{
var out = '';
var col = 0;
var j, k;

for (j = 0; j < text.length; j++) {
if (text[j] != '\t') {
out += text[j];
col++;
continue;
}

k = 8 - (col % 8);
col += k;

do {
out += ' ';
} while (--k > 0);

col += k;
}

return (out);
}

0 comments on commit 69a3902

Please sign in to comment.