From ef18827104bd1fd4746b259fa2fc84ab61d39cf0 Mon Sep 17 00:00:00 2001 From: km1chno Date: Mon, 26 Aug 2024 14:37:25 +0200 Subject: [PATCH 1/3] fix: handle removed files in git status --- src/commands/react-native-ci-cli.ts | 1 + src/extensions/diff.ts | 13 ++++++++----- src/extensions/furtherActions.ts | 1 - src/recipes/build-release.ts | 8 ++++++-- src/recipes/detox.ts | 11 +++-------- src/recipes/jest.ts | 2 +- src/recipes/prettier.ts | 6 +++++- src/templates/detox/test-detox-android.ejf | 2 +- src/templates/detox/test-detox-ios.ejf | 2 +- 9 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/commands/react-native-ci-cli.ts b/src/commands/react-native-ci-cli.ts index 7663a4f..97739f3 100644 --- a/src/commands/react-native-ci-cli.ts +++ b/src/commands/react-native-ci-cli.ts @@ -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()) { diff --git a/src/extensions/diff.ts b/src/extensions/diff.ts index 1267dc9..8621a0b 100644 --- a/src/extensions/diff.ts +++ b/src/extensions/diff.ts @@ -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]) ) @@ -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( @@ -146,7 +149,7 @@ module.exports = (toolbox: CycliToolbox) => { type Status = 'added' | 'modified' | 'deleted' -type Snapshot = Map +type Snapshot = Map type Diff = Map< string, diff --git a/src/extensions/furtherActions.ts b/src/extensions/furtherActions.ts index 9a832a8..aedea09 100644 --- a/src/extensions/furtherActions.ts +++ b/src/extensions/furtherActions.ts @@ -19,7 +19,6 @@ module.exports = (toolbox: CycliToolbox) => { toolbox.interactive.info(`${S_ACTION_BULLET} ${action}`, 'cyan') }) toolbox.interactive.sectionFooter({ color: 'cyan' }) - toolbox.interactive.vspace() } } diff --git a/src/recipes/build-release.ts b/src/recipes/build-release.ts index a067afe..5ee3a6f 100644 --- a/src/recipes/build-release.ts +++ b/src/recipes/build-release.ts @@ -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}` diff --git a/src/recipes/detox.ts b/src/recipes/detox.ts index d9693ab..78059a8 100644 --- a/src/recipes/detox.ts +++ b/src/recipes/detox.ts @@ -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' @@ -34,6 +34,8 @@ const addDetoxExpoPlugin = async (toolbox: CycliToolbox) => { return config }) + addTerminatingNewline(appJsonFile) + toolbox.interactive.step(`Added ${DETOX_EXPO_PLUGIN} plugin to app.json`) } } @@ -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 = diff --git a/src/recipes/jest.ts b/src/recipes/jest.ts index d408028..ca6eebe 100644 --- a/src/recipes/jest.ts +++ b/src/recipes/jest.ts @@ -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({ diff --git a/src/recipes/prettier.ts b/src/recipes/prettier.ts index 8952130..f0f6553 100644 --- a/src/recipes/prettier.ts +++ b/src/recipes/prettier.ts @@ -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', + 'prettierrc.json', + 'prettier.config.js', +] const existsPrettierConfiguration = (toolbox: CycliToolbox): boolean => Boolean(toolbox.projectConfig.packageJson().prettier) || diff --git a/src/templates/detox/test-detox-android.ejf b/src/templates/detox/test-detox-android.ejf index 082a216..4b3a457 100644 --- a/src/templates/detox/test-detox-android.ejf +++ b/src/templates/detox/test-detox-android.ejf @@ -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 diff --git a/src/templates/detox/test-detox-ios.ejf b/src/templates/detox/test-detox-ios.ejf index 3b6afc4..a7b390d 100644 --- a/src/templates/detox/test-detox-ios.ejf +++ b/src/templates/detox/test-detox-ios.ejf @@ -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 From 9ba16e3f0cc739bc7516e4ede64ac3b5a79798c9 Mon Sep 17 00:00:00 2001 From: km1chno Date: Mon, 26 Aug 2024 14:41:15 +0200 Subject: [PATCH 2/3] remove GH_TOKEN info from readme --- readme.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/readme.md b/readme.md index dcdc2c4..263e922 100644 --- a/readme.md +++ b/readme.md @@ -98,14 +98,6 @@ as you will always be prompted to create secrets if necessary. The following tab EXPO_TOKEN Used for authentication in workflows using your Expo account. Learn more at Expo with GitHub actions. - - GH_TOKEN - - Used by workflows reading status of other GitHub actions. You can learn how to generate the token at - Managing your personal access tokens. - Make sure that your generated token has read access to actions. - - ## 💬 Your feedback From 23fc9942a28036655eb2b7581b45163c07ae6384 Mon Sep 17 00:00:00 2001 From: km1chno Date: Mon, 26 Aug 2024 15:55:39 +0200 Subject: [PATCH 3/3] change check for prettier config file --- src/recipes/jest.ts | 2 +- src/recipes/lint.ts | 12 +++--------- src/recipes/prettier.ts | 10 +++------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/recipes/jest.ts b/src/recipes/jest.ts index ca6eebe..c2ecd7e 100644 --- a/src/recipes/jest.ts +++ b/src/recipes/jest.ts @@ -5,7 +5,7 @@ const FLAG = 'jest' const existsJestConfiguration = (toolbox: CycliToolbox): boolean => Boolean(toolbox.projectConfig.packageJson().jest) || - Boolean(toolbox.filesystem.list()?.some((f) => f.includes('jest.config.'))) + Boolean(toolbox.filesystem.list()?.some((f) => f.startsWith('jest.config.'))) const execute = () => async (toolbox: CycliToolbox, context: ProjectContext) => { diff --git a/src/recipes/lint.ts b/src/recipes/lint.ts index 2e09404..f636275 100644 --- a/src/recipes/lint.ts +++ b/src/recipes/lint.ts @@ -4,20 +4,14 @@ import { FLAG as PRETTIER_FLAG } from './prettier' const FLAG = 'lint' -const ESLINT_CONFIGURATION_FILES = [ - '.eslintrc.js', - '.eslintrc.json', - 'eslint.config.js', - 'eslint.config.mjs', - 'eslint.config.cjs', -] - const existsEslintConfiguration = (toolbox: CycliToolbox): boolean => Boolean(toolbox.projectConfig.packageJson().eslintConfig) || Boolean( toolbox.filesystem .list() - ?.some((f) => ESLINT_CONFIGURATION_FILES.includes(f)) + ?.some( + (f) => f.startsWith('.eslintrc.') || f.startsWith('eslint.config.') + ) ) const execute = diff --git a/src/recipes/prettier.ts b/src/recipes/prettier.ts index f0f6553..94f3248 100644 --- a/src/recipes/prettier.ts +++ b/src/recipes/prettier.ts @@ -3,18 +3,14 @@ import { join } from 'path' export const FLAG = 'prettier' -const PRETTIER_CONFIGURATION_FILES = [ - '.prettierrc', - 'prettierrc.json', - 'prettier.config.js', -] - const existsPrettierConfiguration = (toolbox: CycliToolbox): boolean => Boolean(toolbox.projectConfig.packageJson().prettier) || Boolean( toolbox.filesystem .list() - ?.some((f) => PRETTIER_CONFIGURATION_FILES.includes(f)) + ?.some( + (f) => f.startsWith('.prettierrc') || f.startsWith('.prettier.config.') + ) ) const execute =