Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
5caaeba
add service template
hthetiot Mar 27, 2018
e72a350
update template service
hthetiot Mar 27, 2018
4ae36c9
add unit test for template service
hthetiot Mar 27, 2018
a0dad16
Update README.md
hthetiot Mar 27, 2018
e856b9b
fix service template
hthetiot Mar 27, 2018
5ab1d56
fix travis build template
hthetiot Mar 27, 2018
d89a675
update service template
hthetiot Mar 30, 2018
691a220
add generated swagger
hthetiot Mar 30, 2018
a3b1259
improve service template
hthetiot Mar 30, 2018
9e776f6
update boostrap
hthetiot Mar 30, 2018
060fa45
update service template
hthetiot Mar 30, 2018
a2eaa17
fix default query
hthetiot Mar 30, 2018
89fa77a
add template-base IS_VALID_TEMPLATE_FILE
hthetiot Mar 30, 2018
a13e833
update service template
hthetiot Mar 30, 2018
9b84182
update service template
hthetiot Mar 30, 2018
a010abc
lint templates
hthetiot Mar 30, 2018
a2f3c57
lint templates
hthetiot Mar 30, 2018
9845f33
update Dockerfile
hthetiot Apr 2, 2018
07f80da
add mjson template support
hthetiot Apr 2, 2018
d4b4cd6
generate data/main.mjson and load service and model via mjson on ui
hthetiot Apr 2, 2018
a7730af
update service template
hthetiot Apr 2, 2018
a5eea6e
update service template
hthetiot Apr 3, 2018
7d5db18
use values instead or properties in mjson :)
hthetiot Apr 3, 2018
b4d4d95
jshint
hthetiot Apr 3, 2018
ae3313e
prepate data/main.mjson use in middleware.js and use montagejs/montag…
hthetiot Apr 3, 2018
25e6105
update swagger with deleteDataObject and saveDataObject
hthetiot Apr 3, 2018
c953b4c
update middleware with deleteDataObject and saveDataObject
hthetiot Apr 3, 2018
405be42
update service swagger doc
hthetiot Apr 3, 2018
36ac702
update service swagger doc
hthetiot Apr 3, 2018
e3d07fd
fix service spec
hthetiot Apr 3, 2018
046eb88
add express router example with same middleware, implement CRUD test/…
hthetiot Apr 3, 2018
bf1ff40
fix express static and implement websocket suppor
hthetiot Apr 3, 2018
20f20fe
add webscoket spec (integration+test)
hthetiot Apr 3, 2018
52d8886
jshint
hthetiot Apr 3, 2018
6547c19
data/main.mjson deserializeObject
hthetiot Apr 4, 2018
24b14e6
remove transport from getDataOperationResponse
hthetiot Apr 4, 2018
3a0c76d
add missing templates/service/__name__/doc/index.html
hthetiot Apr 4, 2018
5c4eba6
deserializeObject from main.mjson
hthetiot Apr 5, 2018
9fe28ce
fix docker-compose.yml port
hthetiot Apr 5, 2018
135eca2
use Promise on dataStore Mock
hthetiot Apr 12, 2018
e88de2d
fix model mapping
hthetiot Apr 17, 2018
482a40e
update to DataQuery instead of DataSelector and use model mjson for d…
hthetiot Apr 17, 2018
1b02307
apply review changes
hthetiot Apr 17, 2018
a83bc7e
add cli.js
hthetiot Apr 17, 2018
698c0fa
add service cli to manifest
hthetiot Apr 17, 2018
5d8e862
fix generated spec
hthetiot Apr 17, 2018
1a685c1
simplify saveRawData
hthetiot Apr 17, 2018
e97c07f
simplify saveRawData
hthetiot Apr 17, 2018
79637ff
simplify saveRawData
hthetiot Apr 17, 2018
38c6e5b
update .jshintrc
hthetiot Apr 19, 2018
f8fcd8e
mv .travis.yaml .travis.yml
hthetiot Apr 19, 2018
81b1d94
update service template
hthetiot Apr 30, 2018
f5bab21
dix Docker service
hthetiot Apr 30, 2018
5a459a7
lint
hthetiot Apr 30, 2018
c66151c
lint
hthetiot Apr 30, 2018
877fad4
fix cli.js
hthetiot May 3, 2018
4f62cd1
update service template
hthetiot May 3, 2018
100b429
update service template test and data mjson
hthetiot May 3, 2018
0435f65
fix test service tempalte
hthetiot May 3, 2018
4691595
fix istanbul coverage
hthetiot May 3, 2018
5a36cff
fix Dockerfile
hthetiot May 3, 2018
f40923c
add npm run clean on service template
hthetiot May 3, 2018
3cc39f2
fix service template
hthetiot May 14, 2018
d1de954
fix minit service possible issues
hthetiot Jun 12, 2018
111df09
use montage#master
hthetiot Jun 12, 2018
e2e48d6
Update README.md
hthetiot Jun 13, 2018
4699c1b
fix fetchRawData handle error with stream.dataError
hthetiot Jun 15, 2018
ab97daf
Merge branch 'features/serviceTemplate' of github.com:montagejs/minit…
hthetiot Jun 15, 2018
095cc0a
remove nsp catch stream.dataError
hthetiot Jul 23, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/template-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var MinitError = require("./error").MinitError;

var FILENAME_VARIABLE_START = "__";
var FILENAME_VARIABLE_END = "__";
var IS_VALID_TEMPLATE_FILE = /\.(html|mjson|json|js|css|markdown|md|yml|yaml|Dockerfile|npmignore|gitignore)$/;

exports.TemplateBase = Object.create(Object.prototype, {

Expand Down Expand Up @@ -192,7 +193,7 @@ exports.TemplateBase = Object.create(Object.prototype, {
var path = Path.join(dirname, name);
return qfs.stat(path).then(function(stat) {
var promise;
if (stat.isFile() && /\.(html|json|js|css|markdown|md)$/.test(name)) {
if (stat.isFile() && IS_VALID_TEMPLATE_FILE.test(name)) {
promise = self.processFile(path);
} else if (stat.isDirectory()){
promise = self.processDirectory(path);
Expand Down
2 changes: 1 addition & 1 deletion templates/app/__name__/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"description": "{{description}}",
"dependencies": {
"montage": "~17.0.11",
"montage": "~17.1.1",
"digit": "~3.0.0"
},
"devDependencies": {
Expand Down
28 changes: 14 additions & 14 deletions templates/package/__name__/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "{{name}}",
"version": "0.1.0",
"dependencies": {
"montage": "~17.0.11"
},
"devDependencies": {
"montage-testing": "~0.5.1"
},
"exclude": [
"overview.html",
"overview",
"run-tests.html",
"test"
]
"name": "{{name}}",
"version": "0.1.0",
"dependencies": {
"montage": "~17.0.11"
},
"devDependencies": {
"montage-testing": "~0.5.1"
},
"exclude": [
"overview.html",
"overview",
"run-tests.html",
"test"
]
}
138 changes: 138 additions & 0 deletions templates/service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
var PackageTemplate = require("./package").Template;
var TemplateBase = require("../lib/template-base.js").TemplateBase;
var ArgumentError = require("../lib/error.js").ArgumentError;
var path = require('path');
var fs = require('fs');
var npm = require("npm");
var Q = require('q');
var removeDiacritics = require("diacritics").remove;

var ALPHA_UPPER_REG = /([A-Z])/g,
ALPHA_LOWER_REG = /-([a-z])/g,
SEPARATOR1_REG = /--/g,
SEPARATOR2_REG = /^-/;

var _fromCamelToDashes = function(name) {
var s1 = name.replace(ALPHA_UPPER_REG, function (g) {
return "-" + g.toLowerCase();
});
s1 = s1.replace(SEPARATOR1_REG, "-").replace(SEPARATOR2_REG, "");
return s1;
};
var _fromDashesToCamel = function(name) {
var s1 = name.replace(ALPHA_LOWER_REG, function (g) {
return g[1].toUpperCase();
});
s1 = s1[0].toUpperCase() + s1.slice(1);
return s1;
};

exports.Template = Object.create(PackageTemplate, {

commandDescription: {
value: "service"
},

addOptions: {
value:function (command) {
command = PackageTemplate.addOptions.call(this, command);
command.option('-n, --name <name>', 'service name (required)');
command.option('-e, --exported-name [name]', 'exported name');
command.option('-c, --copyright [path]', 'copyright file');
return command;
}
},

didSetOptions: {
value:function (options) {
if (!options.extensionName) {
options.extensionName = "js";
}

if (options.name) {
options.name = this.validateName(options.name, options);
} else {
throw new ArgumentError("Required name option missing");
}
if (!options.exportedName) {
options.exportedName = this.validateExport(options.name);
}
if (options.copyright) {
options.copyright = this.validateCopyright(options.copyright);
}
}
},

validateName: {
value: function(name, options) {
var exportedName = this.validateExport(name);
// convert back from camelcase to dashes and ensure names are ascii
name = removeDiacritics(_fromCamelToDashes(exportedName));

// cleanup the extension
var extensionName = options.extensionName,
extensionPattern, result;

if (extensionName) {
extensionPattern = new RegExp("(\\w*)(\." + extensionName + ")$");

// strip the extension if there is one
result = extensionPattern.exec(name);
if (result !== null) {
name = result[1];
}
}
return name;
}
},


validateExport: {
value: function(name) {
// We accept the name in any format, dashed, spaced or camelcased
// We then convert to to camelcase and back to get the consistent
// naming used in Montage
// remove spaces
name = name.replace(/ /g, "-");
// convert to camelcase
return _fromDashesToCamel(name);
}
},

validateCopyright: {
value: function(path) {
return fs.readFileSync(path, "utf-8");
}
},

defaultPackageHome: {
value: function (value) {
return process.cwd();
}
},

finish: {
value: function(destination) {
var self = this;
return TemplateBase.finish.call(this).then(function() {
var config = {
prefix : path.join(destination, self.options.name),
production : true,
loglevel: "warn"
};
return self.installDependencies(config);
}).then(function() {
return TemplateBase.finish.call(this).then(function() {
console.log("#");
console.log("# "+ self.options.name +" service created, run");
console.log("# > npm run start");
console.log("# to start service via docker-compose");
console.log("#");
console.log("# > npm install .");
console.log("# to set up the testing dependencies");
console.log("#");
});
});
}
},
});
7 changes: 7 additions & 0 deletions templates/service/__name__/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
docker
docker-compose.dev.yml
node_modules
test
coverage
doc
.git
35 changes: 35 additions & 0 deletions templates/service/__name__/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
### General ###
.DS_Store
Thumbs.db
report/
out/
temp/
tmp/
.tmp
*.tmp
*.tmp.*
log.txt
*.log
coverage/

### SublimeText ###
*.sublime-project
*.sublime-workspace

### Intellij IDE ###
.idea/
atlassian-ide-plugin.xml

### VisualStudioCode ###
.vscode/*
.vscode-upload.json

### TextMate ###
*.tmproj
*.tmproject
tmtags

### Node ###
npm-debug.log*
.npmignore
node_modules/
2 changes: 2 additions & 0 deletions templates/service/__name__/.jshintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
coverage
4 changes: 4 additions & 0 deletions templates/service/__name__/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"esversion":6,
"node": true
}
25 changes: 25 additions & 0 deletions templates/service/__name__/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
language: node_js
cache:
directories:
- node_modules
node_js:
# - "9"
# - "8"
# - "6"
- "4"
sudo: required
services:
- docker
before_install:
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
before_script:
- npm prune
script:
- npm run lint
- npm run test
after_failure:
- docker ps
- docker-compose logs
after_success:
- cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
30 changes: 30 additions & 0 deletions templates/service/__name__/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM node:4

ENV APPDIR /usr/src/app

RUN mkdir -p $APPDIR
WORKDIR $APPDIR

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm install --only=production

COPY . $APPDIR
RUN chown -R nobody:nogroup $APPDIR && chmod -R a-w $APPDIR && ls -ld

# Certs
RUN mkdir -p /etc/certs/prod /etc/certs/staging
VOLUME /etc/certs

USER nobody

# Ports > 1024 since we're not root.
EXPOSE 8080 8443 5001

ENTRYPOINT ["node"]
CMD ["."]
3 changes: 3 additions & 0 deletions templates/service/__name__/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{#copyright}}
{{{copyright}}}
{{/copyright}}
Loading