diff --git a/.gitignore b/.gitignore index 82d857e1..e65f52c6 100644 --- a/.gitignore +++ b/.gitignore @@ -54,4 +54,4 @@ typings/ .env*.local # generated js -lib +dist/ diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 055b4370..00000000 --- a/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -.github/ -.prettierrc.js -example/ -src/ -tsconfig.json diff --git a/example/package.json b/example/package.json index bc9153fa..ed5ecb1d 100644 --- a/example/package.json +++ b/example/package.json @@ -5,7 +5,7 @@ "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", - "owl": "node ../lib/cli/index.js", + "owl": "node ../dist/cli/index.js", "owl:build:ios": "yarn owl build --platform ios", "owl:test:ios": "yarn owl test --platform ios", "owl:build:android": "yarn owl build --platform android", diff --git a/src/cli/build.test.ts b/lib/cli/build.test.ts similarity index 98% rename from src/cli/build.test.ts rename to lib/cli/build.test.ts index f7592df9..18bfac3e 100644 --- a/src/cli/build.test.ts +++ b/lib/cli/build.test.ts @@ -2,7 +2,7 @@ import path from 'path'; import execa from 'execa'; import { buildAndroid, buildHandler, buildIOS } from './build'; -import { CliBuildOptions, Config } from './types'; +import { CliBuildOptions, Config } from '../types'; import { Logger } from '../logger'; import * as configHelpers from './config'; diff --git a/src/cli/build.ts b/lib/cli/build.ts similarity index 97% rename from src/cli/build.ts rename to lib/cli/build.ts index e161097d..b504339f 100644 --- a/src/cli/build.ts +++ b/lib/cli/build.ts @@ -1,7 +1,7 @@ import path from 'path'; import execa from 'execa'; -import { CliBuildOptions, Config } from './types'; +import { CliBuildOptions, Config } from '../types'; import { Logger } from '../logger'; import { getConfig } from './config'; diff --git a/src/cli/config.test.ts b/lib/cli/config.test.ts similarity index 99% rename from src/cli/config.test.ts rename to lib/cli/config.test.ts index 7eee8363..8dbdce96 100644 --- a/src/cli/config.test.ts +++ b/lib/cli/config.test.ts @@ -1,6 +1,6 @@ import { promises as fs } from 'fs'; -import { Config } from './types'; +import { Config } from '../types'; import { getConfig, readConfigFile, validateSchema } from './config'; describe('config.ts', () => { diff --git a/src/cli/config.ts b/lib/cli/config.ts similarity index 98% rename from src/cli/config.ts rename to lib/cli/config.ts index dcaee886..32d5ad28 100644 --- a/src/cli/config.ts +++ b/lib/cli/config.ts @@ -1,7 +1,7 @@ import { promises as fs } from 'fs'; import Ajv, { ErrorObject, JSONSchemaType } from 'ajv'; -import { Config } from './types'; +import { Config } from '../types'; export const validateSchema = (config: {}): Promise => { const configSchema: JSONSchemaType = { diff --git a/src/cli/index.ts b/lib/cli/index.ts similarity index 100% rename from src/cli/index.ts rename to lib/cli/index.ts diff --git a/src/cli/run.test.ts b/lib/cli/run.test.ts similarity index 99% rename from src/cli/run.test.ts rename to lib/cli/run.test.ts index 72ff458c..2a3e497a 100644 --- a/src/cli/run.test.ts +++ b/lib/cli/run.test.ts @@ -1,7 +1,7 @@ import path from 'path'; import execa, { ExecaReturnValue } from 'execa'; -import { CliRunOptions, Config } from './types'; +import { CliRunOptions, Config } from '../types'; import { Logger } from '../logger'; import * as configHelpers from './config'; import * as run from './run'; @@ -197,7 +197,7 @@ describe('run.ts', () => { const expectedJestCommand = `jest --config=${path.join( process.cwd(), - 'src', + 'lib', 'jest-config.json' )} --roots=${path.join(process.cwd())} --runInBand`; diff --git a/src/cli/run.ts b/lib/cli/run.ts similarity index 98% rename from src/cli/run.ts rename to lib/cli/run.ts index a02faf2d..e039bf2f 100644 --- a/src/cli/run.ts +++ b/lib/cli/run.ts @@ -1,7 +1,7 @@ import path from 'path'; import execa from 'execa'; -import { CliRunOptions, Config } from './types'; +import { CliRunOptions, Config } from '../types'; import { getConfig } from './config'; import { Logger } from '../logger'; diff --git a/src/index.ts b/lib/index.ts similarity index 100% rename from src/index.ts rename to lib/index.ts diff --git a/src/jest-config.json b/lib/jest-config.json similarity index 100% rename from src/jest-config.json rename to lib/jest-config.json diff --git a/src/logger.test.ts b/lib/logger.test.ts similarity index 100% rename from src/logger.test.ts rename to lib/logger.test.ts diff --git a/src/logger.ts b/lib/logger.ts similarity index 100% rename from src/logger.ts rename to lib/logger.ts diff --git a/src/matchers.test.ts b/lib/matchers.test.ts similarity index 100% rename from src/matchers.test.ts rename to lib/matchers.test.ts diff --git a/src/matchers.ts b/lib/matchers.ts similarity index 97% rename from src/matchers.ts rename to lib/matchers.ts index 350db185..113796d7 100644 --- a/src/matchers.ts +++ b/lib/matchers.ts @@ -3,7 +3,7 @@ import path from 'path'; import pixelmatch from 'pixelmatch'; import { PNG } from 'pngjs'; -import { Platform } from './cli/types'; +import { Platform } from './types'; declare global { namespace jest { diff --git a/src/take-screenshot.test.ts b/lib/take-screenshot.test.ts similarity index 100% rename from src/take-screenshot.test.ts rename to lib/take-screenshot.test.ts diff --git a/src/take-screenshot.ts b/lib/take-screenshot.ts similarity index 97% rename from src/take-screenshot.ts rename to lib/take-screenshot.ts index 7a39f10f..8b64aeaf 100644 --- a/src/take-screenshot.ts +++ b/lib/take-screenshot.ts @@ -4,7 +4,7 @@ import path from 'path'; import { fileExists } from './utils/file-exists'; import { Logger } from './logger'; -import { Platform } from './cli/types'; +import { Platform } from './types'; /** * Takes a screenshot from the simulator. diff --git a/src/cli/types.ts b/lib/types.ts similarity index 100% rename from src/cli/types.ts rename to lib/types.ts diff --git a/src/utils/file-exists.test.ts b/lib/utils/file-exists.test.ts similarity index 100% rename from src/utils/file-exists.test.ts rename to lib/utils/file-exists.test.ts diff --git a/src/utils/file-exists.ts b/lib/utils/file-exists.ts similarity index 100% rename from src/utils/file-exists.ts rename to lib/utils/file-exists.ts diff --git a/package.json b/package.json index 8a78fed8..d6aeb0a3 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,20 @@ "name": "react-native-owl", "version": "0.0.1", "description": "Visual regression testing for React Native", - "main": "./lib/index.js", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "bin": { - "owl": "./lib/cli/index.js" + "owl": "./dist/cli/index.js" }, + "files": [ + "dist/", + "README.md" + ], "scripts": { "build": "tsc", "watch": "tsc --watch", - "prettier:check": "prettier --check 'src/**/*.{js,ts,tsx}'", - "prettier:apply": "prettier --write 'src/**/*.{js,ts,tsx}'", + "prettier:check": "prettier --check 'lib/**/*.{js,ts,tsx}'", + "prettier:apply": "prettier --write 'lib/**/*.{js,ts,tsx}'", "test": "yarn jest" }, "repository": "https://github.com/FormidableLabs/react-native-owl.git", @@ -20,7 +25,7 @@ "preset": "ts-jest", "testEnvironment": "node", "testMatch": [ - "**/src/**/*.test.[jt]s" + "**/lib/**/*.test.[jt]s" ] }, "dependencies": { @@ -34,10 +39,10 @@ "@types/jest": "^26.0.19", "@types/pixelmatch": "^5.2.4", "@types/pngjs": "^6.0.1", - "@types/yargs": "^17.0.3", + "@types/yargs": "^17.0.5", "jest": "^26.6.3", "prettier": "^2.4.1", "ts-jest": "^26.4.4", - "typescript": "^4.4.3" + "typescript": "^4.4.4" } } diff --git a/tsconfig.json b/tsconfig.json index 97a12da9..f29cf845 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,101 +1,28 @@ { "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Projects */ - // "incremental": true, /* Enable incremental compilation */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - /* Language and Environment */ "target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ - // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + "lib": ["es5"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ /* Modules */ "module": "commonjs", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ - // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + "rootDir": "./lib", /* Specify the root folder within your source files. */ "resolveJsonModule": true, /* Enable importing .json files */ - // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ /* Emit */ "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./lib", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + "outDir": "./dist", /* Specify an output folder for all emitted files. */ /* Interop Constraints */ - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ /* Type Checking */ "strict": true, /* Enable all strict type-checking options. */ "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ - // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ }, - "include": ["src/**/*", "src/jest-config.json"] + "include": ["lib/**/*", "lib/jest-config.json"], + "exclude": ["node_modules", "dist"] } diff --git a/yarn.lock b/yarn.lock index d0c2f95e..59a81c6e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -592,10 +592,10 @@ dependencies: "@types/yargs-parser" "*" -"@types/yargs@^17.0.3": - version "17.0.3" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.3.tgz#e6c552aa3277b21a8e802019d03ee5e77894cf27" - integrity sha512-K7rm3Ke3ag/pAniBe80A6J6fjoqRibvCrl3dRmtXV9eCEt9h/pZwmHX9MzjQVUc/elneQTL4Ky7XKorC71Lmxw== +"@types/yargs@^17.0.5": + version "17.0.5" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.5.tgz#1e7e59a88420872875842352b73618f5e77e835f" + integrity sha512-4HNq144yhaVjJs+ON6A07NEoi9Hh0Rhl/jI9Nt/l/YRjt+T6St/QK3meFARWZ8IgkzoD1LC0PdTdJenlQQi2WQ== dependencies: "@types/yargs-parser" "*" @@ -3512,10 +3512,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@^4.4.3: - version "4.4.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.3.tgz#bdc5407caa2b109efd4f82fe130656f977a29324" - integrity sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA== +typescript@^4.4.4: + version "4.4.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c" + integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA== union-value@^1.0.0: version "1.0.1"