Add react-captcha, react-test package

This commit is contained in:
Jerko Steiner 2019-11-01 17:53:21 -04:00
parent e726b1f32d
commit b5325a050d
20 changed files with 140 additions and 23 deletions

28
package-lock.json generated
View File

@ -2360,7 +2360,11 @@
"version": "file:packages/argparse"
},
"@rondo.dev/captcha": {
"version": "file:packages/captcha"
"version": "file:packages/captcha",
"requires": {
"express": "^4.17.1",
"svg-captcha": "^1.4.0"
}
},
"@rondo.dev/client": {
"version": "file:packages/client",
@ -2409,6 +2413,7 @@
"@rondo.dev/comments-server": {
"version": "file:packages/comments-server",
"requires": {
"@rondo.dev/comments-client": "0.0.1",
"@rondo.dev/comments-common": "0.0.1",
"@rondo.dev/common": "0.0.1",
"@rondo.dev/config": "0.0.1",
@ -2487,6 +2492,22 @@
"express": "^4.17.1"
}
},
"@rondo.dev/react-captcha": {
"version": "file:packages/react-captcha",
"requires": {
"react": "^16.11.0"
}
},
"@rondo.dev/react-test": {
"version": "file:packages/react-test",
"requires": {
"@rondo.dev/redux": "0.0.1",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-redux": "^7.1.1",
"redux": "^4.0.4"
}
},
"@rondo.dev/redux": {
"version": "file:packages/redux",
"requires": {
@ -12446,7 +12467,6 @@
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/opentype.js/-/opentype.js-0.7.3.tgz",
"integrity": "sha1-QPuM4Yv9YOdESO/f5EKDQJg5eqs=",
"dev": true,
"requires": {
"tiny-inflate": "^1.0.2"
}
@ -15336,7 +15356,6 @@
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/svg-captcha/-/svg-captcha-1.4.0.tgz",
"integrity": "sha512-/fkkhavXPE57zRRCjNqAP3txRCSncpMx3NnNZL7iEoyAtYwUjPhJxW6FQTQPG5UPEmCrbFoXS10C3YdJlW7PDg==",
"dev": true,
"requires": {
"opentype.js": "^0.7.3"
}
@ -15643,8 +15662,7 @@
"tiny-inflate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/tiny-inflate/-/tiny-inflate-1.0.2.tgz",
"integrity": "sha1-k9nez/yIBb1X6uQxDwt0Xptvs6c=",
"dev": true
"integrity": "sha1-k9nez/yIBb1X6uQxDwt0Xptvs6c="
},
"tiny-invariant": {
"version": "1.0.6",

View File

@ -22,7 +22,8 @@
"@rondo.dev/db-typeorm": "file:packages/db-typeorm",
"@rondo.dev/middleware": "file:packages/middleware",
"@rondo.dev/captcha": "file:packages/captcha",
"@rondo.dev/react-captcha": "file:packages/react-captcha"
"@rondo.dev/react-captcha": "file:packages/react-captcha",
"@rondo.dev/react-test": "file:packages/react-test"
},
"devDependencies": {
"@types/bcrypt": "^3.0.0",
@ -128,4 +129,4 @@
"watchify": "^3.11.1"
},
"name": "node"
}
}

View File

@ -8,8 +8,17 @@
"compile": "tsc",
"clean": "rm -rf lib/"
},
"dependencies": {},
"dependencies": {
"express": "^4.17.1",
"svg-captcha": "^1.4.0"
},
"main": "lib/index.js",
"module": "esm/index.js",
"types": "lib/index.d.ts"
"types": "lib/index.d.ts",
"devDependencies": {
"@rondo.dev/test-utils": "0.0.1",
"cookie-parser": "^1.4.4",
"express-session": "^1.17.0",
"supertest": "^4.0.2"
}
}

View File

@ -9,4 +9,4 @@
"path": "../test-utils"
}
]
}
}

View File

@ -17,6 +17,7 @@
"@rondo.dev/http-client": "0.0.1",
"@rondo.dev/http-types": "0.0.1",
"@rondo.dev/jsonrpc": "0.0.1",
"@rondo.dev/react-test": "0.0.1",
"@rondo.dev/redux": "0.0.1",
"bloomer": "^0.6.5",
"history": "^4.10.1",

View File

@ -1 +1 @@
export * from './TestUtils'
export * from '@rondo.dev/react-test'

View File

@ -17,6 +17,9 @@
{
"path": "../jsonrpc"
},
{
"path": "../react-test"
},
{
"path": "../redux"
},

View File

@ -8,8 +8,11 @@
"compile": "tsc",
"clean": "rm -rf lib/"
},
"dependencies": {},
"dependencies": {
"react": "^16.11.0"
},
"main": "lib/index.js",
"module": "esm/index.js",
"types": "lib/index.d.ts"
"types": "lib/index.d.ts",
"devDependencies": {}
}

View File

@ -59,8 +59,7 @@ export class Captcha extends React.PureComponent<CaptchaProps, CaptchaState> {
</a>
</>
)}
k
<input value={value} onChange={onChange} />
<input key={attempt} value={value} onChange={onChange} />
</div>
)
}

View File

@ -0,0 +1 @@
export * from './Captcha'

View File

@ -4,6 +4,5 @@
"outDir": "lib",
"rootDir": "src"
},
"references": [
]
}
"references": []
}

View File

@ -0,0 +1,16 @@
module.exports = {
roots: [
'<rootDir>/src',
],
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: '(/__tests__/.*|\\.(test|spec))\\.tsx?$',
moduleFileExtensions: [
'ts',
'tsx',
'js',
'jsx',
],
setupFiles: ['<rootDir>/jest.setup.js'],
}

View File

@ -0,0 +1,4 @@
if (!process.env.LOG) {
process.env.LOG = 'sql:warn'
}
process.chdir(__dirname)

View File

@ -0,0 +1,22 @@
{
"name": "@rondo.dev/react-test",
"version": "0.0.1",
"private": true,
"scripts": {
"test": "jest",
"lint": "tslint --project .",
"compile": "tsc",
"clean": "rm -rf lib/"
},
"dependencies": {
"@rondo.dev/redux": "0.0.1",
"react": "^16.11.0",
"react-dom": "^16.11.0",
"react-redux": "^7.1.1",
"redux": "^4.0.4"
},
"main": "lib/index.js",
"module": "esm/index.js",
"types": "lib/index.d.ts",
"devDependencies": {}
}

View File

@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "esm"
},
"references": [
]
}

View File

@ -0,0 +1,12 @@
{
"extends": "../tsconfig.common.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"references": [
{
"path": "../redux"
}
]
}

View File

@ -35,6 +35,7 @@ function writeJSON<T>(filename: string, object: T) {
export function imports(...argv: string[]) {
const args = argparse({
packagesDir: arg('string', {default: 'packages/', positional: true}),
'package': arg('string'),
root: arg('string', {default: './package.json'}),
dryRun: arg('boolean'),
testFileRegex: arg('string', {default: '\\.test\\.(t|j)sx?$'}),
@ -95,14 +96,24 @@ export function imports(...argv: string[]) {
return !moduleName.startsWith('.')
}
function getModule(sourceFile: ts.SourceFile, node: ts.Node) {
if (ts.isImportDeclaration(node)) {
return node.moduleSpecifier.getText(sourceFile)
}
if (ts.isExportDeclaration(node) && node.moduleSpecifier) {
return node.moduleSpecifier.getText(sourceFile)
}
}
/**
* Visit nodes finding exported classes
*/
function visit(sourceFile: ts.SourceFile, node: ts.Node) {
if (ts.isImportDeclaration(node)) {
const text = node.moduleSpecifier.getText(sourceFile)
const name = text.substring(1, text.length - 1)
const moduleWithQuotes = getModule(sourceFile, node)
if (moduleWithQuotes) {
const name = moduleWithQuotes.substring(1, moduleWithQuotes.length - 1)
if (isInstalledModule(name)) {
debug(' %s', name)
let resolved: string
try {
resolved = require.resolve(name)
@ -127,6 +138,7 @@ export function imports(...argv: string[]) {
for (const sourceFile of program.getSourceFiles()) {
if (!sourceFile.isDeclarationFile) {
debug(relative(projectDir, sourceFile.fileName))
ts.forEachChild(sourceFile, visit.bind(null, sourceFile))
}
}
@ -240,6 +252,8 @@ export function imports(...argv: string[]) {
.filter(absoluteDep => absoluteDep.startsWith(absolutePackagesDir))
.map(findPackageRoot)
.map(pkgRoot => relative(projectDir, pkgRoot))
// filter out packages in local node_modules
.filter(path => !path.startsWith('node_modules'))
.map(path => ({ path }))
debug('references: %o', tsConfig.references)
@ -247,7 +261,11 @@ export function imports(...argv: string[]) {
return {filename, json: tsConfig}
}
const result = getFolders(args.packagesDir)
const folders = args.package
? [join(args.packagesDir, args.package)]
: getFolders(args.packagesDir)
const result = folders
.map(pkgDir => {
error('Entering: %s', pkgDir)
const tsConfigFileName = 'tsconfig.json'

View File

@ -14,6 +14,9 @@
{
"path": "../common"
},
{
"path": "../common"
},
{
"path": "../config"
},
@ -42,4 +45,4 @@
"path": "../validator"
}
]
}
}