Skip to content

Commit

Permalink
Merge pull request #10 from bearmini/bower-support
Browse files Browse the repository at this point in the history
support bower
  • Loading branch information
Evgeny Poberezkin committed Feb 29, 2016
2 parents a7fc009 + 6ee4ed8 commit f707a62
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,9 @@ node_modules
# Compiled templates
localize/**/*.js
!localize/index.js

# Browserified tests
.browser

# bundles
dist/
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@ Please contribute locales that you need to use if they are missing.

## Install

Using npm:

```
npm install ajv-i18n
```

Using bower:

```
bower install ajv-i18n
cd bower_components/ajv-i18n
npm install && npm run bundle-all
```

## Usage

Expand Down
27 changes: 27 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "ajv-i18n",
"description": "Internationalised error messages for avj JSON-Schema Validator",
"main": "dist/ajv-i18n.min.js",
"authors": [
"Evgeny Poberezkin"
],
"license": "MIT",
"keywords": [
"ajv",
"JSON",
"schema",
"i18n",
"internationalisation"
],
"homepage": "https://github.com/epoberezkin/ajv-i18n",
"moduleType": [
"amd",
"globals",
"node"
],
"ignore": [
"node_modules",
"bower_components",
"spec"
]
}
57 changes: 57 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Karma configuration
// Generated on Fri Feb 26 2016 16:59:16 GMT+0900 (JST)

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha'],


// list of files / patterns to load in the browser
files: [
'dist/ajv-i18n.test.min.js',
'.browser/*.spec.js'
],


// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['dots'],


// web server port
port: 9876,


// enable / disable colors in the output (reporters and logs)
colors: true,


// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,


// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,


// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],


// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,

browserNoActivityTimeout: 90000
})
}
25 changes: 21 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@
],
"scripts": {
"build": "node scripts/compile-locales.js",
"bundle-all": "npm run browserify && npm run uglify",
"bundle-test": "npm run browserify-test && npm run uglify-test",
"browserify": "mkdir -p dist/ && browserify -r ./localize/index -o dist/ajv-i18n.bundle.js",
"browserify-test": "mkdir -p dist/ && browserify -r ./node_modules/ajv/lib/ajv.js:ajv -r ./localize/index -o dist/ajv-i18n.test.bundle.js",
"uglify": "uglifyjs ./dist/ajv-i18n.bundle.js -o ./dist/ajv-i18n.min.js -m -c",
"uglify-test": "uglifyjs ./dist/ajv-i18n.test.bundle.js -o ./dist/ajv-i18n.test.min.js -m -c",
"prepublish": "npm run build",
"test": "npm run build && mocha spec/*.spec.js -R spec"
"test": "npm run build && mocha spec/*.spec.js -R spec && npm run test-browser",
"test-browser": "npm run bundle-test && scripts/prepare-tests && karma start --single-run --browsers PhantomJS"
},
"repository": {
"type": "git",
Expand All @@ -30,14 +37,24 @@
},
"homepage": "https://github.com/epoberezkin/ajv-i18n#readme",
"devDependencies": {
"ajv": "^2.0.0-beta.2",
"ajv": ">=2.0.0",
"brfs": "^1.4.3",
"browserify": "^13.0.0",
"dot": "^1.0.3",
"jasmine-core": "^2.4.1",
"js-beautify": "^1.5.10",
"json-schema-test": "^0.1.4",
"karma": "^0.13.21",
"karma-jasmine": "^0.3.7",
"karma-mocha": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.0",
"mocha": "^2.3.2",
"pre-commit": "^1.1.1"
"phantomjs-prebuilt": "^2.1.4",
"pre-commit": "^1.1.1",
"require-globify": "^1.3.0",
"uglifyjs": "^2.4.10"
},
"peerDependencies": {
"ajv": "^2.0.0-beta.2"
"ajv": ">=2.0.0"
}
}
10 changes: 10 additions & 0 deletions scripts/prepare-tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -e

mkdir -p .browser

find spec -type f -name '*.spec.js' | \
xargs -I {} sh -c \
'export f="{}"; browserify $f -t require-globify -t brfs -x ajv -u buffer -o $(echo $f | sed -e "s/spec/.browser/");'

24 changes: 21 additions & 3 deletions spec/localize.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ instances.forEach(addRemoteRefs);

jsonSchemaTest(instances, {
description: 'Schema tests of ' + instances.length + ' ajv instances with option i18n',
suites: {
'JSON-Schema tests draft4': './JSON-Schema-Test-Suite/tests/draft4/{**/,}*.json',
},
suites: testSuites(),
afterEach: afterEach,
skip: [
'optional/zeroTerminatedFloats'
Expand All @@ -35,6 +33,26 @@ jsonSchemaTest(instances, {
timeout: 30000
});

function testSuites() {
if (typeof window == 'object') {
var suites = {
'JSON-Schema tests draft4': require('./JSON-Schema-Test-Suite/tests/draft4/{**/,}*.json', {
mode: 'list'
})
};
for (var suiteName in suites) {
suites[suiteName].forEach(function(suite) {
suite.test = suite.module;
});
}
} else {
var suites = {
'JSON-Schema tests draft4': './JSON-Schema-Test-Suite/tests/draft4/{**/,}*.json',
}
}
return suites;
}

function afterEach(res) {
if (res.valid) return;
for (var locale in localize) {
Expand Down

0 comments on commit f707a62

Please sign in to comment.