From 008960efd8e2ce9b4bf84f6c6843ae15f1c2c19c Mon Sep 17 00:00:00 2001 From: Mike Hardy Date: Wed, 18 May 2022 18:22:20 -0500 Subject: [PATCH 1/3] fix(ios, scriptPhases): allow detailed scriptPhases object in config WIP align the joi schema for scriptPhases with the actually allowed values --- .../cli-config/src/__tests__/index-test.ts | 15 +++++++++- packages/cli-config/src/schema.ts | 30 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/packages/cli-config/src/__tests__/index-test.ts b/packages/cli-config/src/__tests__/index-test.ts index 91458dfd1..ebffe7d4a 100644 --- a/packages/cli-config/src/__tests__/index-test.ts +++ b/packages/cli-config/src/__tests__/index-test.ts @@ -97,7 +97,20 @@ test('should read a config of a dependency and use it to load other settings', ( dependency: { platforms: { ios: { - scriptPhases: ["./customLocation/custom.sh"] + scriptPhases: [ + { + name: "[TEST] Some Configuration", + path: "./customLocation/custom.sh", + execution_position: "after_compile", + input_files: ["input_file"], + shell_path: "some/shell/path/bash", + output_files: ["output_file"], + input_file_lists: ["input_file_1", "input_file_2"], + output_file_lists: ["output_file_1", "output_file_2"], + show_env_vars_in_log: false, + dependency_file: "/path/to/dependency/file" + } + ] } } } diff --git a/packages/cli-config/src/schema.ts b/packages/cli-config/src/schema.ts index c777f273d..ef5199d1b 100644 --- a/packages/cli-config/src/schema.ts +++ b/packages/cli-config/src/schema.ts @@ -123,7 +123,35 @@ export const projectConfig = t .object({ podspecPath: t.string(), configurations: t.array().items(t.string()).default([]), - scriptPhases: t.array().items(t.string()).default([]), + scriptPhases: t + .array() + .items( + t.alternatives().try( + t.string(), + map(t.string(), t.any()).keys({ + name: t.string(), + path: t.string(), + execution_position: t + .string() + .valid('before_compile', 'after_compile', 'any') + .allow(null), + input_files: t.array().items(t.string()).allow(null), + shell_path: t.string().allow(null), + output_files: t.array().items(t.string()).allow(null), + input_file_lists: t + .array() + .items(t.string()) + .allow(null), + output_file_lists: t + .array() + .items(t.string()) + .allow(null), + show_env_vars_in_log: t.bool().allow(null), + dependency_file: t.string().allow(null), + }), + ), + ) + .default([]), }) .allow(null), android: t From 99bced378ee51c9d5cc9cf63d9d41e91363579d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Fri, 20 May 2022 11:25:37 +0200 Subject: [PATCH 2/3] fix: bring back object type to scripPhases validation --- .../__snapshots__/index-test.ts.snap | 28 ++++++++++++++-- .../cli-config/src/__tests__/index-test.ts | 2 +- packages/cli-config/src/schema.ts | 32 ++----------------- 3 files changed, 29 insertions(+), 33 deletions(-) diff --git a/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap b/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap index d70378976..c229660cd 100644 --- a/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap +++ b/packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap @@ -51,7 +51,10 @@ Object { "configurations": Array [], "podspecPath": "<>/node_modules/react-native-test/ReactNativeTest.podspec", "scriptPhases": Array [ - "./abc", + Object { + "name": "abc", + "path": "./phase.sh", + }, ], }, }, @@ -68,7 +71,28 @@ Object { "configurations": Array [], "podspecPath": "<>/node_modules/react-native-test/ReactNativeTest.podspec", "scriptPhases": Array [ - "./customLocation/custom.sh", + Object { + "dependency_file": "/path/to/dependency/file", + "execution_position": "after_compile", + "input_file_lists": Array [ + "input_file_1", + "input_file_2", + ], + "input_files": Array [ + "input_file", + ], + "name": "[TEST] Some Configuration", + "output_file_lists": Array [ + "output_file_1", + "output_file_2", + ], + "output_files": Array [ + "output_file", + ], + "path": "./customLocation/custom.sh", + "shell_path": "some/shell/path/bash", + "show_env_vars_in_log": false, + }, ], }, }, diff --git a/packages/cli-config/src/__tests__/index-test.ts b/packages/cli-config/src/__tests__/index-test.ts index ebffe7d4a..4b2096b77 100644 --- a/packages/cli-config/src/__tests__/index-test.ts +++ b/packages/cli-config/src/__tests__/index-test.ts @@ -146,7 +146,7 @@ test('should merge project configuration with default values', () => { "react-native-test": { platforms: { ios: { - scriptPhases: ["./abc"] + scriptPhases: [{name: "abc", path: "./phase.sh"}] } }, } diff --git a/packages/cli-config/src/schema.ts b/packages/cli-config/src/schema.ts index ef5199d1b..e0c62e5ef 100644 --- a/packages/cli-config/src/schema.ts +++ b/packages/cli-config/src/schema.ts @@ -69,7 +69,7 @@ export const dependencyConfig = t ios: t // IOSDependencyParams .object({ - scriptPhases: t.array().items(t.string()), + scriptPhases: t.array().items(t.object()), configurations: t.array().items(t.string()).default([]), }) .default({}), @@ -123,35 +123,7 @@ export const projectConfig = t .object({ podspecPath: t.string(), configurations: t.array().items(t.string()).default([]), - scriptPhases: t - .array() - .items( - t.alternatives().try( - t.string(), - map(t.string(), t.any()).keys({ - name: t.string(), - path: t.string(), - execution_position: t - .string() - .valid('before_compile', 'after_compile', 'any') - .allow(null), - input_files: t.array().items(t.string()).allow(null), - shell_path: t.string().allow(null), - output_files: t.array().items(t.string()).allow(null), - input_file_lists: t - .array() - .items(t.string()) - .allow(null), - output_file_lists: t - .array() - .items(t.string()) - .allow(null), - show_env_vars_in_log: t.bool().allow(null), - dependency_file: t.string().allow(null), - }), - ), - ) - .default([]), + scriptPhases: t.array().items(t.object()), }) .allow(null), android: t From 5ab98953722e1ff7711d093dce28004b384a1ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Fri, 20 May 2022 11:39:29 +0200 Subject: [PATCH 3/3] fix: default to empty array --- packages/cli-config/src/schema.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli-config/src/schema.ts b/packages/cli-config/src/schema.ts index e0c62e5ef..6871329ae 100644 --- a/packages/cli-config/src/schema.ts +++ b/packages/cli-config/src/schema.ts @@ -123,7 +123,7 @@ export const projectConfig = t .object({ podspecPath: t.string(), configurations: t.array().items(t.string()).default([]), - scriptPhases: t.array().items(t.object()), + scriptPhases: t.array().items(t.object()).default([]), }) .allow(null), android: t