Yuki Takei 9 ani în urmă
părinte
comite
4b3673327b

+ 16 - 0
packages/growi-commons/.babelrc

@@ -0,0 +1,16 @@
+{
+  "presets": [
+    "es2015"
+  ],
+  "plugins": [
+    "add-module-exports",
+    "transform-class-properties"
+  ],
+  "env": {
+    "development": {
+      "presets": [
+        "power-assert"
+      ]
+    }
+  }
+}

+ 13 - 0
packages/growi-commons/.editorconfig

@@ -0,0 +1,13 @@
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+indent_size = 2
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+insert_final_newline = false
+trim_trailing_whitespace = false

+ 36 - 0
packages/growi-commons/.gitignore

@@ -0,0 +1,36 @@
+# Logs
+logs
+*.log
+npm-debug.log.*
+
+# OS generated files #
+.DS_Store
+.Trash-*
+ehthumbs.db
+Icon?
+Thumbs.db
+
+# Node Files #
+/node_modules/
+/bower_components/
+npm-debug.log
+/npm-debug.log.*
+
+# Dist #
+/dist
+/lib
+/public/__build__/
+/src/*/__build__/
+/__build__/**
+/public/dist/
+/src/*/dist/
+/.awcache
+.webpack.json
+/compiled/
+
+# Doc #
+/doc/
+
+# IDE #
+.idea
+.vscode

+ 21 - 0
packages/growi-commons/LICENSE

@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Yuki Takei
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 38 - 0
packages/growi-commons/package.json

@@ -0,0 +1,38 @@
+{
+  "name": "crowi-pluginkit",
+  "version": "1.0.0",
+  "description": "The Crowi Plugin Kit to develop plugins",
+  "files": [
+    "lib"
+  ],
+  "scripts": {
+    "build": "babel src --out-dir lib --source-maps inline",
+    "clean": "npm cache clean && npm run rimraf -- lib",
+    "prebuild": "npm run clean",
+    "watch": "babel src --out-dir lib --watch --source-maps inline",
+    "rimraf": "rimraf",
+    "test": "mocha --compilers js:babel-register test/*.js"
+  },
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/yuki-takei/crowi-pluginkit.git"
+  },
+  "author": "Yuki Takei <yuki@weseek.co.jp>",
+  "license": "MIT",
+  "bugs": {
+    "url": "https://github.com/yuki-takei/crowi-pluginkit/issues"
+  },
+  "homepage": "https://github.com/yuki-takei/crowi-pluginkit#readme",
+  "dependencies": {
+  },
+  "devDependencies": {
+    "babel-cli": "^6.23.0",
+    "babel-plugin-add-module-exports": "^0.2.1",
+    "babel-plugin-transform-class-properties": "^6.23.0",
+    "babel-preset-es2015": "^6.22.0",
+    "babel-preset-power-assert": "^1.0.0",
+    "babel-register": "^6.23.0",
+    "power-assert": "^1.4.2",
+    "rimraf": "^2.6.1"
+  }
+}

+ 47 - 0
packages/growi-commons/src/lib/util/BasicInterceptor.js

@@ -0,0 +1,47 @@
+/**
+ * Basic Interceptor class
+ */
+class BasicInterceptor {
+
+  /**
+   * getter for id
+   */
+  getId() {
+    return this.constructor.name;
+  }
+
+  /**
+   * return whether this interceptor works by specified contextName
+   *
+   * @param {string} contextName
+   * @return {boolean}
+   */
+  isInterceptWhen(contextName) {
+    // implement this
+    return false;
+  }
+
+  /**
+   * return whether this interceptor processes in parallel mode or sequencial mode
+   * @return {boolean}
+   */
+  isProcessableParallel() {
+    // implement this
+    return true;
+  }
+
+  /**
+   * process method
+   *
+   * @param {string} contextName
+   * @param {any} args
+   * @return {Promise}
+   */
+  process(contextName, ...args) {
+    // override this
+    return Promise.resolve(...args);
+  }
+
+}
+
+module.exports = BasicInterceptor;