Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle removed files in git status #77

Merged
merged 3 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,6 @@ as you will always be prompted to create secrets if necessary. The following tab
<td style="vertical-align: middle;">EXPO_TOKEN</td>
<td style="vertical-align: middle;">Used for authentication in workflows using your Expo account. Learn more at <a href=https://docs.expo.dev/eas-update/github-actions>Expo with GitHub actions</a>.</td>
</tr>
<tr>
<td style="vertical-align: middle;">GH_TOKEN</td>
<td style="vertical-align: middle;">
Used by workflows reading status of other GitHub actions. You can learn how to generate the token at
<a href=https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens>Managing your personal access tokens</a>.
Make sure that your generated token has <ins>read access to actions</ins>.
</td>
</tr>
</table>

## 💬 Your feedback
Expand Down
1 change: 1 addition & 0 deletions src/commands/react-native-ci-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const runReactNativeCiCli = async (toolbox: CycliToolbox) => {

const usedFlags = executorResults.join(' ')

toolbox.interactive.vspace()
toolbox.interactive.success(`We're all set 🎉`)

if (!toolbox.options.isPreset()) {
Expand Down
13 changes: 8 additions & 5 deletions src/extensions/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ module.exports = (toolbox: CycliToolbox) => {
let expandedPathsList: [Status, string][] = []

for (const [status, path] of pathsList) {
const expandedPaths = await expandDirectory(
context.path.absFromRepoRoot(path)
)
const expandedPaths =
status === 'deleted'
? [context.path.absFromRepoRoot(path)]
: await expandDirectory(context.path.absFromRepoRoot(path))

expandedPathsList = expandedPathsList.concat(
expandedPaths.map((expandedPath) => [status, expandedPath])
)
Expand All @@ -65,7 +67,8 @@ module.exports = (toolbox: CycliToolbox) => {
return await Promise.all(
expandedPathsList.map(async ([status, path]: [Status, string]) => ({
path,
checksum: await generateFileChecksum(path),
checksum:
status === 'deleted' ? undefined : await generateFileChecksum(path),
status,
}))
).then(
Expand Down Expand Up @@ -146,7 +149,7 @@ module.exports = (toolbox: CycliToolbox) => {

type Status = 'added' | 'modified' | 'deleted'

type Snapshot = Map<string, { checksum: string; status: Status }>
type Snapshot = Map<string, { checksum?: string; status: Status }>

type Diff = Map<
string,
Expand Down
1 change: 0 additions & 1 deletion src/extensions/furtherActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module.exports = (toolbox: CycliToolbox) => {
toolbox.interactive.info(`${S_ACTION_BULLET} ${action}`, 'cyan')
})
toolbox.interactive.sectionFooter({ color: 'cyan' })
toolbox.interactive.vspace()
}
}

Expand Down
8 changes: 6 additions & 2 deletions src/recipes/build-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ const createReleaseBuildWorkflowAndroid = async (
context: ProjectContext,
{ expo }: { expo: boolean }
) => {
let script =
'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release'
let script = [
'cd android &&',
'./gradlew assembleRelease assembleAndroidTest',
'-DtestBuildType=release',
'-Dorg.gradle.jvmargs=-Xmx4g',
].join(' ')

if (expo) {
script = `npx expo prebuild --${context.packageManager} && ${script}`
Expand Down
11 changes: 3 additions & 8 deletions src/recipes/detox.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { REPOSITORY_SECRETS_HELP_URL } from '../constants'
import { CycliRecipe, CycliToolbox, ProjectContext, RunResult } from '../types'
import { addTerminatingNewline } from '../utils/addTerminatingNewline'
import { createReleaseBuildWorkflows } from './build-release'
import { join } from 'path'

Expand Down Expand Up @@ -34,6 +34,8 @@ const addDetoxExpoPlugin = async (toolbox: CycliToolbox) => {
return config
})

addTerminatingNewline(appJsonFile)

toolbox.interactive.step(`Added ${DETOX_EXPO_PLUGIN} plugin to app.json`)
}
}
Expand Down Expand Up @@ -118,13 +120,6 @@ const createDetoxWorkflows = async (
await toolbox.workflows.generate(join('detox', 'test-detox-ios.ejf'), context)

toolbox.interactive.success('Created Detox workflow.')

toolbox.interactive.warning(
`Remember to create GH_TOKEN repository secret to make Detox workflow work.For more information check ${REPOSITORY_SECRETS_HELP_URL} `
)
toolbox.furtherActions.push(
`Create GH_TOKEN repository secret.More info at ${REPOSITORY_SECRETS_HELP_URL} `
)
}

const execute =
Expand Down
2 changes: 1 addition & 1 deletion src/recipes/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const execute =

await toolbox.dependencies.addDev('jest', context)

await toolbox.scripts.add('test', 'jest')
await toolbox.scripts.add('test', 'jest --passWithNoTests')

if (!existsJestConfiguration(toolbox)) {
await toolbox.template.generate({
Expand Down
6 changes: 5 additions & 1 deletion src/recipes/prettier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { join } from 'path'

export const FLAG = 'prettier'

const PRETTIER_CONFIGURATION_FILES = ['.prettierrc', 'prettier.config.js']
const PRETTIER_CONFIGURATION_FILES = [
'.prettierrc',
km1chno marked this conversation as resolved.
Show resolved Hide resolved
'prettierrc.json',
'prettier.config.js',
]

const existsPrettierConfiguration = (toolbox: CycliToolbox): boolean =>
Boolean(toolbox.projectConfig.packageJson().prettier) ||
Expand Down
2 changes: 1 addition & 1 deletion src/templates/detox/test-detox-android.ejf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: ⌛ Wait for build to finish
uses: poseidon/wait-for-status-checks@v0.5.0
with:
token: ${{ secrets.GH_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
delay: 20s
match_pattern: build-release-android

Expand Down
2 changes: 1 addition & 1 deletion src/templates/detox/test-detox-ios.ejf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: ⌛ Wait for build to finish
uses: poseidon/wait-for-status-checks@v0.5.0
with:
token: ${{ secrets.GH_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
delay: 20s
match_pattern: build-release-ios

Expand Down