cumulocity-hellowidget-plugin
Advanced tools
Comparing version 2.3.0 to 2.4.0
const _ = require('lodash'); | ||
const glob = require('glob'); | ||
const { readJsonSync } = require('fs-extra'); | ||
const { join, dirname } = require('path'); | ||
const { resolve, dirname } = require('path'); | ||
const APP_CONTEXT_PATH = process.argv[4] || 'hellowidgetapp'; | ||
// const APP_CONTEXT_PATH = process.argv[4] || 'helloapp'; | ||
const pluginJsFiles = _(glob.sync('plugins/**/*/cumulocity.json')) | ||
const pluginJsFiles = _(glob.sync('plugins/*/cumulocity.json')) | ||
.flatMap(manifestFile => | ||
@@ -14,6 +14,6 @@ _.map(readJsonSync(manifestFile).js, jsFile => { | ||
if (jsFile.match(/^(node_modules|bower_components)/i)) { | ||
baseDir = join(baseDir, '../..'); | ||
baseDir = resolve(baseDir, '../..'); | ||
} | ||
return join(baseDir, jsFile); | ||
return resolve(baseDir, jsFile); | ||
}) | ||
@@ -26,3 +26,3 @@ ) | ||
config.set({ | ||
singleRun: true, | ||
singleRun: false, | ||
@@ -32,8 +32,6 @@ files: [ | ||
'node_modules/angular-mocks/angular-mocks.js', | ||
'node_modules/sinon/pkg/sinon.js', | ||
'node_modules/tentacle.js/dist/tentacle.js', | ||
'test-helper.js', | ||
...pluginJsFiles, | ||
'plugins/**/*.spec.js', | ||
'plugins/**/*.html' | ||
'plugins/*/**/*.spec.js', // match plugins/p/x.spec.js but not plugins/x.spec.js, | ||
'plugins/*/**/*.html' | ||
], | ||
@@ -46,7 +44,7 @@ | ||
plugins: [ | ||
'karma-jasmine', | ||
'karma-chrome-launcher', | ||
'karma-spec-reporter', | ||
'karma-ng-html2js-preprocessor', | ||
'karma-babel-preprocessor', | ||
require('karma-jasmine'), | ||
require('karma-chrome-launcher'), | ||
require('karma-spec-reporter'), | ||
require('karma-ng-html2js-preprocessor'), | ||
require('karma-babel-preprocessor'), | ||
{ 'preprocessor:c8y-pluginpath': ['factory', c8yPluginPathPreprocessor] } | ||
@@ -56,10 +54,5 @@ ], | ||
preprocessors: { | ||
'test-helper.js': ['babel'], | ||
// Match files in all plugins subfolders except vendor/ or lib/. | ||
'plugins/*/{*.js,!(vendor)/**/*.js,!(lib)/**/*.js}': [ | ||
'c8y-pluginpath', | ||
'babel' | ||
], | ||
'plugins/**/*.html': ['ng-html2js'] | ||
'plugins/*/{*.js,!(vendor)/**/*.js,!(lib)/**/*.js}': ['c8y-pluginpath', 'babel'], | ||
'plugins/*/**/*.html': ['c8y-pluginpath', 'ng-html2js'] | ||
}, | ||
@@ -78,11 +71,7 @@ | ||
ngHtml2JsPreprocessor: { | ||
cacheIdFromPath: filepath => filepath.replace(/^plugins\//i, ''), | ||
cacheIdFromPath: filepath => filepath.replace(/^plugins\//, ''), | ||
moduleName: 'c8yHtml.test' | ||
}, | ||
logLevel: config.LOG_ERROR, | ||
client: { | ||
captureConsole: true | ||
} | ||
logLevel: config.LOG_ERROR | ||
}); | ||
@@ -93,17 +82,6 @@ }; | ||
return (content, file, done) => { | ||
done( | ||
content.replace( | ||
/:::PLUGIN_PATH:::/g, | ||
computePluginPath(file.originalPath) | ||
) | ||
); | ||
const [, pluginName] = file.originalPath.match(/plugins\/(.+?)\//); | ||
done(content.replace(/:::PLUGIN_PATH:::/g, pluginName)); | ||
}; | ||
} | ||
function computePluginPath(filepath) { | ||
const pluginName = /plugins\/(.+?)\/+?/.exec(filepath)[1]; | ||
//const pluginPath = `${APP_CONTEXT_PATH}_${pluginName}`; | ||
const pluginPath = pluginName; | ||
return pluginPath; | ||
} |
{ | ||
"name": "cumulocity-hellowidget-plugin", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "A demo app for showcasing creation of a custom Cumulocity UI widget plugin", | ||
@@ -38,30 +38,26 @@ "keywords": [ | ||
"dependencies": { | ||
"cumulocity-ui-build": "http://resources.cumulocity.com/webapps/ui/9.8.2.tar.gz" | ||
"cumulocity-ui-build": "http://resources.cumulocity.com/webapps/ui/9.15.1.tar.gz" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.1.2", | ||
"@babel/plugin-proposal-object-rest-spread": "7.0.0", | ||
"@babel/preset-env": "7.1.0", | ||
"angular-mocks": "1.6.6", | ||
"babel-core": "6.26.3", | ||
"babel-eslint": "8.2.3", | ||
"babel-plugin-transform-object-rest-spread": "6.26.0", | ||
"babel-preset-env": "1.7.0", | ||
"cumulocity-tools": "2.1.14", | ||
"eslint": "4.19.1", | ||
"eslint-config-airbnb-base": "12.1.0", | ||
"eslint-config-prettier": "2.9.0", | ||
"eslint-plugin-import": "2.12.0", | ||
"fs-extra": "6.0.1", | ||
"glob": "7.1.2", | ||
"jasmine-core": "3.1.0", | ||
"karma": "2.0.3", | ||
"karma-babel-preprocessor": "7.0.0", | ||
"cumulocity-tools": "2.1.20", | ||
"eslint": "5.7.0", | ||
"eslint-config-airbnb-base": "13.1.0", | ||
"eslint-config-prettier": "3.1.0", | ||
"eslint-plugin-import": "2.14.0", | ||
"fs-extra": "7.0.0", | ||
"glob": "7.1.3", | ||
"jasmine-core": "3.2.1", | ||
"karma": "3.0.0", | ||
"karma-babel-preprocessor": "8.0.0-beta.0", | ||
"karma-chrome-launcher": "2.2.0", | ||
"karma-jasmine": "1.1.2", | ||
"karma-ng-html2js-preprocessor": "1.0.0", | ||
"karma-phantomjs-launcher": "1.0.4", | ||
"karma-spec-reporter": "0.0.32", | ||
"lodash": "4.17.10", | ||
"prettier": "1.13.5", | ||
"sinon": "6.0.0", | ||
"tentacle.js": "0.1.0" | ||
"lodash": "4.17.11", | ||
"prettier": "1.14.3" | ||
} | ||
} |
{ | ||
"name": "Hello Widget", | ||
"description": "Simple hello widget plugin", | ||
"category": "Boilerplate", | ||
"category": "Boilerplates", | ||
"ngModules": ["helloWidgetApp.helloWidget"], | ||
@@ -6,0 +6,0 @@ "js": [ |
@@ -17,2 +17,3 @@ /** | ||
/* @ngInject */ | ||
function Controller() { | ||
@@ -19,0 +20,0 @@ const vm = this; |
@@ -8,18 +8,5 @@ /** | ||
let $injector; | ||
let $rootScope; | ||
let $compile; | ||
it('component should exist', () => { | ||
const { $injector } = setup(); | ||
beforeEach(() => { | ||
common.globalBeforeWithUI(); | ||
angular.mock.module('helloWidgetApp.helloWidget'); | ||
inject(_$injector_ => { | ||
$injector = _$injector_; | ||
$rootScope = $injector.get('$rootScope'); | ||
$compile = $injector.get('$compile'); | ||
}); | ||
}); | ||
it('component should exist', () => { | ||
expect($injector.has('c8yHelloTextInputDirective')).toEqual(true); | ||
@@ -29,6 +16,2 @@ }); | ||
describe('configuring text', () => { | ||
beforeEach(() => { | ||
//////////// stubbing dependencies | ||
}); | ||
it('should correctly configure text by default', () => { | ||
@@ -60,2 +43,3 @@ // given | ||
function createComponent(template, bindings) { | ||
const { $rootScope, $compile } = setup(); | ||
const $scope = _.assign($rootScope.$new(), bindings); | ||
@@ -69,2 +53,17 @@ | ||
}); | ||
function setup() { | ||
const setupVariables = {}; | ||
common.globalBeforeWithUI(); | ||
angular.mock.module('helloWidgetApp.helloWidget'); | ||
inject(($injector) => _.assign(setupVariables, { | ||
$injector, | ||
$rootScope: $injector.get('$rootScope'), | ||
$compile: $injector.get('$compile') | ||
})); | ||
return setupVariables; | ||
} | ||
}); |
@@ -17,2 +17,3 @@ /** | ||
/* @ngInject */ | ||
function Controller() { | ||
@@ -19,0 +20,0 @@ const vm = this; |
@@ -7,4 +7,2 @@ # cumulocity-hellowidget-plugin | ||
#### *** Heads-up! Since version 2.X, this Cumulocity UI plugin boilerplate is written in ES6+. 🎉 *** | ||
A demo app for showcasing creation of a custom Cumulocity UI widget plugin. | ||
@@ -16,3 +14,3 @@ | ||
## Installation | ||
* Make sure you have Node.js ≥ v8.9.0 installed and npm from its [website](https://nodejs.org), or better even, use [nvm](https://github.com/creationix/nvm). | ||
* Make sure you have Node.js LTS installed and npm from its [website](https://nodejs.org), or better even, use [nvm](https://github.com/creationix/nvm). | ||
@@ -54,3 +52,3 @@ - Install [yarn](https://yarnpkg.com/en/docs/install). | ||
```bash | ||
$ yarn lint <targetFileOrDir> | ||
$ yarn lint <target_file_or_dir> | ||
``` | ||
@@ -63,3 +61,3 @@ | ||
Or better yet, make your IDE automatically integrate the linting process based on the .rc file (`.eslintrc.yaml`). | ||
Or better yet, make your IDE automatically integrate the linting process based on the .rc file (`.eslintrc`). | ||
@@ -66,0 +64,0 @@ The rules quite strictly follow the [Airbnb JavaScript Style Guide (ES6+ without React)](https://github.com/airbnb/javascript). |
(() => { | ||
'use strict'; | ||
initBackendMocks(); | ||
window.c8y_testing = true; | ||
@@ -11,47 +11,39 @@ window.common = { | ||
patchCurrentUserBackend(); | ||
//////////// | ||
function initBackendMocks() { | ||
angular.module('c8y.backendMocks', []).run(runBlock); | ||
/* @ngInject */ | ||
function runBlock($httpBackend) { | ||
$httpBackend.when('GET', /\/user\/currentUser(.*)/).respond({}); | ||
} | ||
} | ||
function globalBeforeWithUI() { | ||
globalBefore(); | ||
module('c8y.ui'); | ||
angular.mock.module('c8y.ui'); | ||
} | ||
function globalBefore() { | ||
module($provide => { | ||
/* | ||
* Best to keep the below "magic" fake info data for unit testing purpose, | ||
* otherwise some services may not be able to be injected properly, | ||
* errors maybe thrown from the minified (cumulocity-ui-build) files, and | ||
* you don't wanna waste your time debugging the build files and will most | ||
* likely have no clue on what's going wrong. You've been warned (!) :) | ||
*/ | ||
angular.mock.module(($provide) => { | ||
$provide.value('info', { | ||
appKey: 'test', | ||
beta: 'test', | ||
appConfig: { manifest: {} }, | ||
appName: 'test', | ||
appLoadedJson: 'test', | ||
logout: 'test', | ||
hideAppEdit: 'test', | ||
baseUrl: '/', | ||
pageSize: 50, | ||
preventGetUser: true, | ||
languages: ['en'], | ||
skipSwitchingToDefaultLanguage: true, | ||
test: true | ||
skipSwitchingToDefaultLanguage: true | ||
}); | ||
}); | ||
module('c8y.core'); | ||
module('c8y.backendMocks'); | ||
module('c8yHtml.test'); | ||
angular.mock.module('c8y.core'); | ||
angular.mock.module('c8y.currentUserBackendPatch'); | ||
const jestEnabled = window.test; | ||
if (!jestEnabled) { | ||
angular.mock.module('c8yHtml.test'); | ||
} | ||
} | ||
function patchCurrentUserBackend() { | ||
angular | ||
.module('c8y.currentUserBackendPatch', []) | ||
.run(runBlock); | ||
/* @ngInject */ | ||
function runBlock( | ||
$httpBackend | ||
) { | ||
$httpBackend.whenGET(/\/user\/currentUser(.*)/) | ||
.respond({}); | ||
} | ||
} | ||
})(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
HTTP dependency
Supply chain riskContains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
HTTP dependency
Supply chain riskContains a dependency which resolves to a remote HTTP URL which could be used to inject untrusted code and reduce overall package reliability.
Found 1 instance in 1 package
20
5773833
23
387
69