@youlai/rn-tools 0.0.0-stage → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,63 @@
1
1
  {
2
2
  "name": "@youlai/rn-tools",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.3",
4
+ "description": "React Native 项目级工具箱,支持版本号、构建号、bundle id、显示名、图标生成、体检和清理",
5
+ "keywords": [
6
+ "react-native",
7
+ "bundle-id",
8
+ "android",
9
+ "ios",
10
+ "cli"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://git.youlai.cn/fe/packages.git"
15
+ },
16
+ "license": "ISC",
17
+ "author": "laoona@163.com",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./typings/index.d.ts",
21
+ "require": "./index.js",
22
+ "import": "./index.mjs",
23
+ "default": "./index.mjs"
24
+ },
25
+ "./cli": "./cli.js",
26
+ "./package.json": "./package.json"
27
+ },
28
+ "main": "index.js",
29
+ "module": "index.mjs",
30
+ "types": "./typings/index.d.ts",
31
+ "bin": {
32
+ "rn-tools": "cli.js"
33
+ },
34
+ "files": [
35
+ "*.js",
36
+ "*.mjs",
37
+ "typings",
38
+ "README.md"
39
+ ],
40
+ "scripts": {
41
+ "build": "npm run build:types && npm run build:index && npm run build:cli",
42
+ "build:cli": "vite build --config vite.config.ts --mode cli",
43
+ "build:index": "vite build --config vite.config.ts --mode index",
44
+ "build:types": "tsc -p tsconfig.json",
45
+ "clean": "rm -rf dist",
46
+ "release": "npm run build",
47
+ "test": "npm run build && node --test $(find tests -name '*.test.mjs' -print)"
48
+ },
49
+ "dependencies": {
50
+ "picocolors": "^1.1.1",
51
+ "sharp": "^0.34.5"
52
+ },
53
+ "devDependencies": {
54
+ "@types/node": "^22.15.21",
55
+ "rollup-plugin-copy": "^3.5.0",
56
+ "typescript": "^5.8.3",
57
+ "vite": "^5.4.19",
58
+ "vite-plugin-dts": "^4.5.4"
59
+ },
60
+ "engines": {
61
+ "node": ">=18"
62
+ }
6
63
  }
@@ -0,0 +1,6 @@
1
+ import { BundleIdRenameOptions, TaskResult } from './types';
2
+ export declare function validateBundleId(value: string): void;
3
+ export declare function renameBundleId(options: BundleIdRenameOptions): Promise<TaskResult>;
4
+ /** 判断 plist 值是否引用了构建设置,如 $(PRODUCT_BUNDLE_IDENTIFIER)、${PRODUCT_NAME}。 */
5
+ export declare function isBuildSettingReference(value: string): boolean;
6
+ export type { BundleIdRenameOptions, TaskResult } from './types';
@@ -0,0 +1,3 @@
1
+ import { CleanProjectOptions, TaskResult } from './types';
2
+ export declare function cleanProject(options: CleanProjectOptions): Promise<TaskResult>;
3
+ export type { CleanProjectOptions } from './types';
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @author: laoona
4
+ * @date: 2026-06-02
5
+ * @time: 18:43:53
6
+ * @contact: laoona@163.com
7
+ * @description: React Native 项目工具命令行入口
8
+ */
9
+ export {};
@@ -0,0 +1,4 @@
1
+ import { DisplayNameUpdateOptions, TaskResult } from './types';
2
+ export declare function validateDisplayName(value: string): void;
3
+ export declare function updateDisplayName(options: DisplayNameUpdateOptions): Promise<TaskResult>;
4
+ export type { DisplayNameUpdateOptions } from './types';
@@ -0,0 +1,3 @@
1
+ import { DoctorProjectOptions, TaskResult } from './types';
2
+ export declare function doctorProject(options: DoctorProjectOptions): Promise<TaskResult>;
3
+ export type { DoctorProjectOptions } from './types';
@@ -0,0 +1,12 @@
1
+ import { MoveRecord } from './types';
2
+ export declare function pathExists(filePath: string): boolean;
3
+ export declare function readText(filePath: string): string;
4
+ export declare function readTextIfExists(filePath: string): string | null;
5
+ export declare function writeText(filePath: string, content: string, dryRun: boolean): void;
6
+ export declare function replaceText(content: string, replacements: Array<[RegExp, string]>): {
7
+ content: string;
8
+ changed: boolean;
9
+ };
10
+ export declare function listFilesRecursive(rootDir: string): string[];
11
+ export declare function moveDirectoryTree(sourceDir: string, destinationDir: string, dryRun: boolean): MoveRecord[];
12
+ export declare function removePath(targetPath: string, dryRun: boolean): boolean;
@@ -0,0 +1,3 @@
1
+ import { IconSyncOptions, TaskResult } from './types';
2
+ export declare function buildIconAssets(options: IconSyncOptions): Promise<TaskResult>;
3
+ export type { IconSyncOptions } from './types';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @author: laoona
3
+ * @date: 2026-06-02
4
+ * @time: 18:43:54
5
+ * @contact: laoona@163.com
6
+ * @description: React Native 项目工具导出入口
7
+ */
8
+ export { renameBundleId } from './bundle-id';
9
+ export { cleanProject } from './clean';
10
+ export { updateDisplayName } from './display-name';
11
+ export { doctorProject } from './doctor';
12
+ export { buildIconAssets } from './icon';
13
+ export { createConsoleLogger, getLogger } from './logger';
14
+ export { bundleIdTask, cleanTask, createProjectToolRunner, defaultProjectToolRunner, displayNameTask, doctorTask, iconTask, runProjectTask, versionTask } from './tasks';
15
+ export type { AndroidProjectPaths, BundleIdRenameOptions, CleanProjectOptions, ConsoleLoggerOptions, ConsoleLogLevel, DisplayNameUpdateOptions, DoctorProjectOptions, IconBuildConfig, IconSyncOptions, Logger, MoveRecord, ProjectContext, ProjectTask, ProjectToolRunner, TaskResult, VersionUpdateOptions } from './types';
16
+ export { updateVersion } from './version';
@@ -0,0 +1,2 @@
1
+ export declare function findIosInfoPlist(rootDir: string): string;
2
+ export declare function findTopLevelIosFile(rootDir: string, displayName: string, predicate: (iosDir: string, filePath: string) => boolean): string;
@@ -0,0 +1,3 @@
1
+ import { ConsoleLoggerOptions, Logger } from './types';
2
+ export declare function createConsoleLogger(options?: ConsoleLoggerOptions): Logger;
3
+ export declare function getLogger(logger?: Logger, options?: ConsoleLoggerOptions): Logger;
@@ -0,0 +1,10 @@
1
+ import { BundleIdRenameOptions, CleanProjectOptions, DisplayNameUpdateOptions, DoctorProjectOptions, IconSyncOptions, ProjectContext, ProjectTask, ProjectToolRunner, TaskResult, VersionUpdateOptions } from './types';
2
+ export declare const bundleIdTask: ProjectTask<BundleIdRenameOptions>;
3
+ export declare const displayNameTask: ProjectTask<DisplayNameUpdateOptions>;
4
+ export declare const versionTask: ProjectTask<VersionUpdateOptions>;
5
+ export declare const cleanTask: ProjectTask<CleanProjectOptions>;
6
+ export declare const doctorTask: ProjectTask<DoctorProjectOptions>;
7
+ export declare const iconTask: ProjectTask<IconSyncOptions>;
8
+ export declare function createProjectToolRunner(initialTasks?: Array<ProjectTask<unknown>>): ProjectToolRunner;
9
+ export declare const defaultProjectToolRunner: ProjectToolRunner;
10
+ export declare function runProjectTask<TOptions>(name: string, context: ProjectContext, options: TOptions, runner?: ProjectToolRunner): Promise<TaskResult>;
@@ -0,0 +1,140 @@
1
+ /**
2
+ * @author: laoona
3
+ * @date: 2026-06-02
4
+ * @time: 18:43:54
5
+ * @contact: laoona@163.com
6
+ * @description: React Native 项目工具类型定义
7
+ */
8
+ export interface Logger {
9
+ info(message: string): void;
10
+ warn(message: string): void;
11
+ error(message: string): void;
12
+ debug?(message: string): void;
13
+ }
14
+ export type ConsoleLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
15
+ export interface ConsoleLoggerOptions {
16
+ prefix?: string;
17
+ scope?: string;
18
+ level?: ConsoleLogLevel;
19
+ color?: boolean;
20
+ verbose?: boolean;
21
+ quiet?: boolean;
22
+ dryRun?: boolean;
23
+ timestamps?: boolean;
24
+ }
25
+ export interface BundleIdRenameOptions {
26
+ rootDir?: string;
27
+ bundleId: string;
28
+ androidPackage?: string;
29
+ iosBundleId?: string;
30
+ dryRun?: boolean;
31
+ verbose?: boolean;
32
+ quiet?: boolean;
33
+ color?: boolean;
34
+ logger?: Logger;
35
+ }
36
+ export interface DisplayNameUpdateOptions {
37
+ rootDir?: string;
38
+ displayName: string;
39
+ dryRun?: boolean;
40
+ verbose?: boolean;
41
+ quiet?: boolean;
42
+ color?: boolean;
43
+ logger?: Logger;
44
+ }
45
+ export interface VersionUpdateOptions {
46
+ rootDir?: string;
47
+ version?: string;
48
+ buildNumber?: string | number;
49
+ platform?: 'all' | 'android' | 'ios';
50
+ dryRun?: boolean;
51
+ verbose?: boolean;
52
+ quiet?: boolean;
53
+ color?: boolean;
54
+ logger?: Logger;
55
+ }
56
+ export interface IconBuildConfig {
57
+ rootDir?: string;
58
+ sourceImage?: string;
59
+ androidDestinationDir?: string;
60
+ androidAdaptiveIcon?: boolean;
61
+ androidAdaptiveIconBackgroundColor?: string;
62
+ androidAdaptiveIconForegroundScale?: number;
63
+ iosAssetsDir?: string;
64
+ iosIconSetName?: string;
65
+ /** Fill for transparent pixels in iOS icons, which App Store requires to be opaque. */
66
+ iosIconBackgroundColor?: string;
67
+ androidIconName?: string;
68
+ androidRoundIconName?: string;
69
+ }
70
+ export interface IconSyncOptions {
71
+ configPath?: string;
72
+ rootDir?: string;
73
+ sourceImage?: string;
74
+ androidDestinationDir?: string;
75
+ androidAdaptiveIcon?: boolean;
76
+ androidAdaptiveIconBackgroundColor?: string;
77
+ androidAdaptiveIconForegroundScale?: number;
78
+ iosAssetsDir?: string;
79
+ iosIconSetName?: string;
80
+ /** Fill for transparent pixels in iOS icons, which App Store requires to be opaque. */
81
+ iosIconBackgroundColor?: string;
82
+ androidIconName?: string;
83
+ androidRoundIconName?: string;
84
+ dryRun?: boolean;
85
+ verbose?: boolean;
86
+ quiet?: boolean;
87
+ color?: boolean;
88
+ logger?: Logger;
89
+ }
90
+ export interface CleanProjectOptions {
91
+ rootDir?: string;
92
+ dryRun?: boolean;
93
+ verbose?: boolean;
94
+ quiet?: boolean;
95
+ color?: boolean;
96
+ logger?: Logger;
97
+ }
98
+ export interface DoctorProjectOptions {
99
+ rootDir?: string;
100
+ dryRun?: boolean;
101
+ verbose?: boolean;
102
+ quiet?: boolean;
103
+ color?: boolean;
104
+ logger?: Logger;
105
+ }
106
+ export interface MoveRecord {
107
+ from: string;
108
+ to: string;
109
+ }
110
+ export interface TaskResult {
111
+ changedFiles: string[];
112
+ movedFiles: MoveRecord[];
113
+ warnings: string[];
114
+ dryRun: boolean;
115
+ }
116
+ export interface ProjectContext {
117
+ rootDir: string;
118
+ dryRun: boolean;
119
+ verbose: boolean;
120
+ quiet?: boolean;
121
+ color?: boolean;
122
+ logger: Logger;
123
+ }
124
+ export interface ProjectTask<TOptions> {
125
+ name: string;
126
+ description: string;
127
+ run(context: ProjectContext, options: TOptions): Promise<TaskResult> | TaskResult;
128
+ }
129
+ export interface ProjectToolRunner {
130
+ listTasks(): ProjectTask<unknown>[];
131
+ getTask(name: string): ProjectTask<unknown> | undefined;
132
+ registerTask<TOptions>(task: ProjectTask<TOptions>): ProjectToolRunner;
133
+ runTask<TOptions>(name: string, context: ProjectContext, options: TOptions): Promise<TaskResult>;
134
+ }
135
+ export interface AndroidProjectPaths {
136
+ gradle: string;
137
+ manifest: string;
138
+ javaRoot: string;
139
+ kotlinRoot: string;
140
+ }
@@ -0,0 +1,3 @@
1
+ import { TaskResult, VersionUpdateOptions } from './types';
2
+ export declare function updateVersion(options?: VersionUpdateOptions): Promise<TaskResult>;
3
+ export type { VersionUpdateOptions } from './types';