diff --git a/README.md b/README.md index 1b89ede2..ecac97dd 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ The config file - which unless specified in the cli should live in `./owl.config | **ios config** | | | | `ios.workspace` | true | Path to the `.xcworkspace` file of your react-native project | | `ios.scheme` | true | The name of the scheme you would like to use for building the app | +| `ios.configuration` | true | The build configuration that should be used. Defaults to Debug | | `ios.buildCommand` | false | Overrides the `xcodebuild` command making the above options obselete | | `ios.binaryPath` | false | The path to the binary, if you are using a custom build command | | `ios.quiet` | false | Passes the quiet flag to `xcode builds` | diff --git a/example/owl.config.json b/example/owl.config.json index 57d33c37..b3f8a1b6 100644 --- a/example/owl.config.json +++ b/example/owl.config.json @@ -2,6 +2,7 @@ "ios": { "workspace": "ios/OwlDemo.xcworkspace", "scheme": "OwlDemo", + "configuration": "Release", "device": "iPhone 13 Pro", "quiet": true }, diff --git a/src/cli/build.test.ts b/src/cli/build.test.ts index 922f52e8..f7592df9 100644 --- a/src/cli/build.test.ts +++ b/src/cli/build.test.ts @@ -20,6 +20,7 @@ describe('build.ts', () => { ios: { workspace: 'ios/RNDemo.xcworkspace', scheme: 'RNDemo', + configuration: 'Debug', device: 'iPhone Simulator', }, }; @@ -38,6 +39,7 @@ describe('build.ts', () => { ios: { workspace: 'ios/RNDemo.xcworkspace', scheme: 'RNDemo', + configuration: 'Debug', quiet: true, device: 'iPhone Simulator', }, diff --git a/src/cli/build.ts b/src/cli/build.ts index 686aba52..e161097d 100644 --- a/src/cli/build.ts +++ b/src/cli/build.ts @@ -15,7 +15,7 @@ export const buildIOS = async ( `xcodebuild`, `-workspace ${config.ios?.workspace}`, `-scheme ${config.ios?.scheme}`, - `-configuration Debug`, + `-configuration ${config.ios?.configuration}`, `-sdk iphonesimulator`, `-derivedDataPath ios/build`, ]; @@ -24,6 +24,8 @@ export const buildIOS = async ( buildCommand.push('-quiet'); } + logger.info(`[OWL] Building the app with: ${buildCommand.join(' ')}.`); + await execa.command(buildCommand.join(' '), { stdio: 'inherit' }); }; @@ -43,6 +45,8 @@ export const buildAndroid = async ( ? undefined : path.join(process.cwd(), '/android'); + logger.info(`[OWL] Building the app with: ${buildCommand.join(' ')}.`); + await execa.command(buildCommand.join(' '), { stdio: 'inherit', cwd }); }; diff --git a/src/cli/config.test.ts b/src/cli/config.test.ts index 4f400f2f..7eee8363 100644 --- a/src/cli/config.test.ts +++ b/src/cli/config.test.ts @@ -53,6 +53,35 @@ describe('config.ts', () => { await expect(validate()).resolves.toEqual(config); }); + it('accepts a target for iOS', async () => { + const config = { + ios: { + workspace: 'ios/RNDemo.xcworkspace', + scheme: 'Test', + configuration: 'Release', + device: 'iPhone Simulator', + }, + }; + + const result = await validateSchema(config); + + expect(result?.ios?.configuration).toEqual('Release'); + }); + + it('defaults the target to Debug for iOS', async () => { + const config = { + ios: { + workspace: 'ios/RNDemo.xcworkspace', + scheme: 'Test', + device: 'iPhone Simulator', + }, + }; + + const result = await validateSchema(config); + + expect(result?.ios?.configuration).toEqual('Debug'); + }); + it("rejects an ios config that doesn't have either workspace/scheme or buildCommand", async () => { const config = { ios: {} }; @@ -143,10 +172,11 @@ describe('config.ts', () => { describe('getConfig', () => { it('returns a validated config', async () => { - const expectedConfig = { + const expectedConfig: Config = { ios: { workspace: 'ios/RNDemo.xcworkspace', scheme: 'RNDemo', + configuration: 'Debug', device: 'iPhone Simulator', }, android: { diff --git a/src/cli/config.ts b/src/cli/config.ts index 6cbad058..dcaee886 100644 --- a/src/cli/config.ts +++ b/src/cli/config.ts @@ -11,6 +11,7 @@ export const validateSchema = (config: {}): Promise => { type: 'object', properties: { workspace: { type: 'string', nullable: true }, + configuration: { type: 'string', nullable: true, default: 'Debug' }, scheme: { type: 'string', nullable: true }, buildCommand: { type: 'string', nullable: true }, binaryPath: { type: 'string', nullable: true }, @@ -45,7 +46,7 @@ export const validateSchema = (config: {}): Promise => { additionalProperties: false, }; - const ajv = new Ajv(); + const ajv = new Ajv({ useDefaults: true }); const validate = ajv.compile(configSchema); return new Promise((resolve, reject) => { diff --git a/src/cli/run.test.ts b/src/cli/run.test.ts index 45d6cc34..716e7f4e 100644 --- a/src/cli/run.test.ts +++ b/src/cli/run.test.ts @@ -45,6 +45,7 @@ describe('run.ts', () => { ios: { workspace: 'ios/RNDemo.xcworkspace', scheme: 'RNDemo', + configuration: 'Debug', device: 'iPhone Simulator', }, }; diff --git a/src/cli/run.ts b/src/cli/run.ts index b3491091..d7360d84 100644 --- a/src/cli/run.ts +++ b/src/cli/run.ts @@ -14,7 +14,7 @@ export const getIOSBundleIdentifier = (appPath: string): string => { export const runIOS = async (config: Config, logger: Logger) => { const stdio = config.debug ? 'inherit' : 'ignore'; - const DEFAULT_BINARY_DIR = '/ios/build/Build/Products/Debug-iphonesimulator'; + const DEFAULT_BINARY_DIR = `/ios/build/Build/Products/${config.ios?.configuration}-iphonesimulator`; const cwd = config.ios?.binaryPath ? path.dirname(config.ios?.binaryPath) : path.join(process.cwd(), DEFAULT_BINARY_DIR); diff --git a/src/cli/types.ts b/src/cli/types.ts index f3eae45f..6f3f5a0b 100644 --- a/src/cli/types.ts +++ b/src/cli/types.ts @@ -18,6 +18,8 @@ type ConfigIOS = { workspace?: string; /** The scheme to build. */ scheme?: string; + /** The build configuration that should be used for this target. Usually Debug or Release. */ + configuration?: string; /** Overrides the `xcodebuild` command making the workspace & scheme options obselete. */ buildCommand?: string; /** Path to the .app that will get generated by a custom build command. Ignored when not using a custom build command. */ diff --git a/tsconfig.json b/tsconfig.json index 685c0c34..97a12da9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,72 +2,100 @@ "compilerOptions": { /* Visit https://aka.ms/tsconfig.json to read more about this file */ - /* Basic Options */ - // "incremental": true, /* Enable incremental compilation */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ - // "lib": [], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "./lib", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "composite": true, /* Enable project compilation */ - // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + /* 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. */ - /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ - "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + /* 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. */ - /* Additional Checks */ - "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + /* 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. */ + "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. */ - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + /* 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`. */ - /* Source Map Options */ - // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + /* 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. */ - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + /* 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. */ - /* Advanced Options */ - "skipLibCheck": true, /* Skip type checking of declaration files. */ - "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ - "resolveJsonModule": true + /* 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"], - "exclude": ["src/**/*.test.ts"] + "include": ["src/**/*", "src/jest-config.json"] }