Skip to content

Commit

Permalink
fix(ios): allow detailed scriptPhases object in config (#1611)
Browse files Browse the repository at this point in the history
* fix(ios, scriptPhases): allow detailed scriptPhases object in config WIP

align the joi schema for scriptPhases with the actually allowed values

* fix: bring back object type to scripPhases validation

* fix: default to empty array

Co-authored-by: Michał Pierzchała <thymikee@gmail.com>
  • Loading branch information
mikehardy and thymikee committed May 20, 2022
1 parent 810b6a0 commit 5ac83d8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
28 changes: 26 additions & 2 deletions packages/cli-config/src/__tests__/__snapshots__/index-test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ Object {
"configurations": Array [],
"podspecPath": "<<REPLACED>>/node_modules/react-native-test/ReactNativeTest.podspec",
"scriptPhases": Array [
"./abc",
Object {
"name": "abc",
"path": "./phase.sh",
},
],
},
},
Expand All @@ -68,7 +71,28 @@ Object {
"configurations": Array [],
"podspecPath": "<<REPLACED>>/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,
},
],
},
},
Expand Down
17 changes: 15 additions & 2 deletions packages/cli-config/src/__tests__/index-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
}
}
Expand Down Expand Up @@ -133,7 +146,7 @@ test('should merge project configuration with default values', () => {
"react-native-test": {
platforms: {
ios: {
scriptPhases: ["./abc"]
scriptPhases: [{name: "abc", path: "./phase.sh"}]
}
},
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cli-config/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({}),
Expand Down Expand Up @@ -120,7 +120,7 @@ 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.object()).default([]),
})
.allow(null),
android: t
Expand Down

0 comments on commit 5ac83d8

Please sign in to comment.