From fff10a39bd41f71995836b8a4ddeb4af68d9f0f5 Mon Sep 17 00:00:00 2001 From: Chris Herman Date: Mon, 29 Jul 2024 14:49:05 -0400 Subject: [PATCH 1/3] fix: center cli text --- packages/cli/package.json | 2 ++ packages/cli/src/actions/info.ts | 9 ++++++--- yarn.lock | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index f33d93001f..97987d7271 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -22,6 +22,7 @@ "types": "dist/index.d.ts", "dependencies": { "@brandingbrand/code-cli-kit": "13.0.0", + "ansi-align": "^3.0.1", "bundle-require": "^4.0.2", "chalk": "^4.1.2", "ci-info": "^4.0.0", @@ -51,6 +52,7 @@ "@brandingbrand/code-jest-config": "1.0.0", "@repo/eslint-config": "*", "@repo/typescript-config": "*", + "@types/ansi-align": "3.0.5", "@types/eslint": "^8.56.1", "@types/node": "^20.10.6", "@types/react": "^18.2.55", diff --git a/packages/cli/src/actions/info.ts b/packages/cli/src/actions/info.ts index 343a2df92f..fd1b5e2cd1 100644 --- a/packages/cli/src/actions/info.ts +++ b/packages/cli/src/actions/info.ts @@ -6,6 +6,7 @@ import {isWindows} from '@brandingbrand/code-cli-kit'; import pkg from '../../package.json'; import {config, defineAction, logger} from '@/lib'; +import ansiAlign from 'ansi-align'; /** * Executes the default action, providing detailed information and performing necessary checks. @@ -40,11 +41,13 @@ export default defineAction( ▒▒▒▒ `); + logger.info( - chalk.bold - .blue`Welcome to Flagship Code ${chalk.bold.white`v${pkg.version}`}`, + ansiAlign([ + chalk.bold.blue`Flagship Code ${chalk.bold.white`v${pkg.version}`}`, + chalk.dim`Configurable - Extensible - Toolkit`, + ]).join('\n'), ); - logger.info(chalk.dim` Configurable - Extensible - Toolkit`); // Check if the script is running on Windows, and throw an error if it is if (isWindows) { diff --git a/yarn.lock b/yarn.lock index 6dea6c28f0..88481fb17b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3181,6 +3181,11 @@ dependencies: "@types/estree" "*" +"@types/ansi-align@3.0.5": + version "3.0.5" + resolved "https://registry.yarnpkg.com/@types/ansi-align/-/ansi-align-3.0.5.tgz#47302af78848bfcc2432b9050ce81e7c11a6d541" + integrity sha512-W6b8auzVjGP4JS2ejBl9OzwL1N3aBGqY7gamD28GymzcdNVeVGS+jfLeNWO/iknHLWa00hqGPaT3AcXhKax4aA== + "@types/babel__core@^7.1.14", "@types/babel__core@^7.20.4": version "7.20.5" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017" From c920f9690ef51c49c3c232a850d387f64d25615f Mon Sep 17 00:00:00 2001 From: Chris Herman Date: Fri, 2 Aug 2024 10:15:15 -0400 Subject: [PATCH 2/3] fix: plugin-permissions react-native-permissions versions --- .changeset/small-toys-argue.md | 5 ++ .../plugin-permissions/__tests__/index.ts | 14 ++---- packages/plugin-permissions/src/index.ts | 46 +++++++++++-------- 3 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 .changeset/small-toys-argue.md diff --git a/.changeset/small-toys-argue.md b/.changeset/small-toys-argue.md new file mode 100644 index 0000000000..42c220885a --- /dev/null +++ b/.changeset/small-toys-argue.md @@ -0,0 +1,5 @@ +--- +"@brandingbrand/code-plugin-permissions": patch +--- + +utilize react-native-permissions ios setup script. diff --git a/packages/plugin-permissions/__tests__/index.ts b/packages/plugin-permissions/__tests__/index.ts index 5af81e6ed1..2a658f6a56 100644 --- a/packages/plugin-permissions/__tests__/index.ts +++ b/packages/plugin-permissions/__tests__/index.ts @@ -8,8 +8,6 @@ import plugin from '../src'; import type {CodePluginPermissions} from '../src/types'; describe('plugin-permissions', () => { - jest.spyOn(fs, 'writeFile').mockImplementation(jest.fn()); - it('ios', async () => { const config: BuildConfig & CodePluginPermissions = { ios: { @@ -39,13 +37,11 @@ describe('plugin-permissions', () => { await plugin.ios?.(config, {} as any); - expect(fs.writeFile).toHaveBeenCalledWith( - require.resolve('react-native-permissions/RNPermissions.podspec'), - expect.stringContaining( - '"ios/*.{h,m,mm}", "ios/AppTrackingTransparency/*.{h,m,mm}"', - ), - 'utf-8', - ); + expect(await fs.readFile(path.ios.podfile, 'utf-8')) + .toContain(`setup_permissions([ + 'AppTrackingTransparency', + 'LocationAccuracy' +])`); expect(await fs.readFile(path.ios.infoPlist, 'utf-8')) .toContain(`NSUserTrackingUsageDescription Let me use your ad identifier`); diff --git a/packages/plugin-permissions/src/index.ts b/packages/plugin-permissions/src/index.ts index e9d1688e6d..fa29bafc6f 100644 --- a/packages/plugin-permissions/src/index.ts +++ b/packages/plugin-permissions/src/index.ts @@ -11,6 +11,7 @@ import { string, withInfoPlist, withManifest, + path, } from '@brandingbrand/code-cli-kit'; import * as permissions from './permissions'; @@ -36,29 +37,36 @@ export default definePlugin({ // Check if the iOS plugin permissions are defined if (!build.codePluginPermissions.plugin.ios) return; - // Resolve the path for RNPermissions.podspec file - const filePath = require.resolve( - 'react-native-permissions/RNPermissions.podspec', - { - // eslint-disable-next-line turbo/no-undeclared-env-vars - ...(!process.env.JEST_WORKER_ID && {paths: [process.cwd()]}), - }, - ); - // Update podspec file with appropriate permissions - await withUTF8(filePath, content => { - const pods = build.codePluginPermissions.plugin.ios!.reduce( - (acc, curr) => { - const pod = permissions.ios[curr.permission]; + await withUTF8(path.ios.podfile, content => { + const pods = build.codePluginPermissions.plugin.ios?.map( + it => `'${it.permission}'`, + ); - if (!pod?.pod) return acc; + if (!pods) return content; - return `${acc}, "ios/${pod?.pod}/*.{h,m,mm}"`; - }, - '"ios/*.{h,m,mm}"', - ); + const setupPodsString = `setup_permissions([ + ${pods.join(',\n ')} +])`; - return string.replace(content, /(source_files\s+=\s+).*/, `$1${pods}`); + return string.replace( + content, + /(.)/m, + `def node_require(script) + # Resolve script with node to allow for hoisting + require Pod::Executable.execute_command('node', ['-p', + "require.resolve( + '#{script}', + {paths: [process.argv[1]]}, + )", __dir__]).strip +end + +node_require('react-native-permissions/scripts/setup.rb') + +${setupPodsString} + +$1`, + ); }); // Update Info.plist with appropriate permissions and texts From b5d87a5673bb712ed0a1fa1c6154ccc3d50e57dc Mon Sep 17 00:00:00 2001 From: Nick Burkhart Date: Mon, 5 Aug 2024 11:49:43 -0400 Subject: [PATCH 3/3] chore(plugin-permission): version bump for patch fix --- .changeset/small-toys-argue.md | 5 ----- apps/example/package.json | 2 +- packages/plugin-permissions/CHANGELOG.md | 6 ++++++ packages/plugin-permissions/package.json | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) delete mode 100644 .changeset/small-toys-argue.md diff --git a/.changeset/small-toys-argue.md b/.changeset/small-toys-argue.md deleted file mode 100644 index 42c220885a..0000000000 --- a/.changeset/small-toys-argue.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@brandingbrand/code-plugin-permissions": patch ---- - -utilize react-native-permissions ios setup script. diff --git a/apps/example/package.json b/apps/example/package.json index 60bdd5d24a..af93783410 100644 --- a/apps/example/package.json +++ b/apps/example/package.json @@ -41,7 +41,7 @@ "@brandingbrand/code-plugin-asset": "2.0.0", "@brandingbrand/code-plugin-example": "link:./coderc/plugins/plugin-example", "@brandingbrand/code-plugin-native-navigation": "2.0.0", - "@brandingbrand/code-plugin-permissions": "2.0.0", + "@brandingbrand/code-plugin-permissions": "2.0.1", "@brandingbrand/code-plugin-splash-screen": "2.0.0", "@react-native/eslint-config": "^0.72.2", "@react-native/metro-config": "^0.72.11", diff --git a/packages/plugin-permissions/CHANGELOG.md b/packages/plugin-permissions/CHANGELOG.md index 4a257bd2b2..39b0f2fd82 100644 --- a/packages/plugin-permissions/CHANGELOG.md +++ b/packages/plugin-permissions/CHANGELOG.md @@ -1,5 +1,11 @@ # @brandingbrand/code-plugin-permissions +## 2.0.1 + +### Patch Changes + +- c920f96: utilize react-native-permissions ios setup script. + ## 2.0.0 ### Major Changes diff --git a/packages/plugin-permissions/package.json b/packages/plugin-permissions/package.json index d1ccacb112..599aea5b48 100644 --- a/packages/plugin-permissions/package.json +++ b/packages/plugin-permissions/package.json @@ -1,6 +1,6 @@ { "name": "@brandingbrand/code-plugin-permissions", - "version": "2.0.0", + "version": "2.0.1", "description": "plugin for Flagship Code for react-native-permissions", "license": "MIT", "main": "src/index.ts",