From 026d1e03ffa18d22bbe107234d85b32f52cb754e Mon Sep 17 00:00:00 2001 From: Matthias Giger Date: Tue, 16 Jan 2024 16:33:27 +0100 Subject: [PATCH] feat(script): native clear command & use latest RN cli Somehow ended up using "next" CLI tag, which is now causing issues. release-npm --- package.json | 14 +++++++------- script/prompt.ts | 9 ++++++++- template-cache.ts | 1 + template/app/package.json | 8 ++++---- template/default/package.json | 4 ++-- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 9bab000..0c32399 100644 --- a/package.json +++ b/package.json @@ -27,16 +27,16 @@ } }, "dependencies": { - "@react-native-community/cli": "^13.0.0", + "@react-native-community/cli": "^12.3.2", "@react-native/babel-preset": "^0.74.0", "@react-native/eslint-config": "^0.74.0", - "@react-native/metro-config": "^0.73.2", + "@react-native/metro-config": "^0.73.3", "@react-native/typescript-config": "^0.74.0", "arg": "^5.0.2", "command-exists": "^1.2.9", "deepmerge": "^4.3.1", "eslint": "^8.56.0", - "eslint-plugin-prettier": "^5.1.1", + "eslint-plugin-prettier": "^5.1.3", "fast-glob": "^3.3.2", "global-cache-dir": "^6.0.0", "is-ci": "^3.0.1", @@ -44,7 +44,7 @@ "logua": "^3.0.3", "pakag": "^3.1.1", "parse-gitignore": "^2.0.0", - "prettier": "^3.1.1", + "prettier": "^3.2.2", "prompts": "^2.4.2", "semver": "^7.5.4", "semver-sort": "^1.0.0", @@ -55,9 +55,9 @@ "@types/prompts": "^2.4.9", "@types/semver": "^7.5.6", "jest-fixture": "^4.1.0", - "padua": "^2.0.7", - "react-native": "^0.73.1", - "vitest": "^1.1.0" + "padua": "^2.0.8", + "react-native": "^0.73.2", + "vitest": "^1.2.0" }, "peerDependencies": { "react-native": ">= 0.73" diff --git a/script/prompt.ts b/script/prompt.ts index 386fc51..bdedf23 100644 --- a/script/prompt.ts +++ b/script/prompt.ts @@ -12,6 +12,7 @@ import { lint } from './lint' import { ios } from './ios' import { android } from './android' import { RunLocation, RunMode } from '../types' +import { clearTemplateCache } from '../template-cache' const scriptToMethod = { plugin, @@ -133,6 +134,7 @@ export const prompt = async () => { { title: 'Create or update patch', value: 'patch' }, { title: 'Apply existing patch', value: 'apply' }, { title: 'Lint project', value: 'lint' }, + { title: 'Clear native cache', value: 'clear' }, ], }) @@ -144,7 +146,7 @@ export const prompt = async () => { return } - if (script !== 'ios' && script !== 'android' && script !== 'distribute') { + if (script in scriptToMethod) { await scriptToMethod[script]() } @@ -260,4 +262,9 @@ export const prompt = async () => { android({ location, mode, deviceId, simulator }) } } + + if (script === 'clear') { + const directory = clearTemplateCache() + log(`Template cache in ${directory} successfully cleared`) + } } diff --git a/template-cache.ts b/template-cache.ts index bbb7435..1270817 100644 --- a/template-cache.ts +++ b/template-cache.ts @@ -73,4 +73,5 @@ export const cacheTemplate = (nativeOptions: NativeOptions) => { export const clearTemplateCache = () => { const templates = readdirSync(cacheDirectory) templates.forEach((template) => rmSync(join(cacheDirectory, template), { recursive: true })) + return cacheDirectory } diff --git a/template/app/package.json b/template/app/package.json index 7d176e4..00f2581 100644 --- a/template/app/package.json +++ b/template/app/package.json @@ -18,20 +18,20 @@ "mobx": "^6.12.0", "mobx-react-lite": "^4.0.5", "react": "^18.2.0", - "react-native": "^0.73.1", + "react-native": "^0.73.2", "reactigation": "^4.0.2", - "responsive-react-native": "^1.0.2" + "responsive-react-native": "^1.0.3" }, "devDependencies": { "@testing-library/jest-native": "^5.4.3", - "@testing-library/react-native": "^12.4.2", + "@testing-library/react-native": "^12.4.3", "@types/jest": "^29.5.11", "@types/react-native": "^0.72.8", "android-sdk-numic-plugin": "^1.0.3", "babel-jest": "^29.7.0", "icon-numic-plugin": "^1.4.3", "jest": "^29.7.0", - "numic": "^2.0.5", + "numic": "^2.1.0", "react-test-renderer": "^18.2.0", "typescript": "^5.3.3" }, diff --git a/template/default/package.json b/template/default/package.json index 7abb9b8..8f02522 100644 --- a/template/default/package.json +++ b/template/default/package.json @@ -15,7 +15,7 @@ }, "dependencies": { "react": "^18.2.0", - "react-native": "^0.73.1" + "react-native": "^0.73.2" }, "type": "module", "devDependencies": { @@ -26,7 +26,7 @@ "babel-jest": "^29.7.0", "icon-numic-plugin": "^1.4.3", "jest": "^29.7.0", - "numic": "^2.0.5", + "numic": "^2.1.0", "react-test-renderer": "18.2.0", "typescript": "^5.3.3" },