forked from microsoft/react-native-macos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
107 lines (94 loc) · 2.78 KB
/
index.js
File metadata and controls
107 lines (94 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// @ts-check
const {REPO_ROOT} = require('../../scripts/consts');
const JsVersionActions = require('@nx/js/src/release/version-actions').default;
const fs = require('node:fs');
const path = require('node:path');
/**
* @returns {Promise<string[]>}
*/
async function runSetVersion() {
const rnmPkgJsonPath = path.join(REPO_ROOT, 'packages', 'react-native', 'package.json');
const {updateReactNativeArtifacts} = require('../../scripts/releases/set-rn-artifacts-version');
const manifest = fs.readFileSync(rnmPkgJsonPath, {encoding: 'utf-8'});
const {version} = JSON.parse(manifest);
await updateReactNativeArtifacts(version);
return [
path.join(
REPO_ROOT,
'packages',
'react-native',
'ReactAndroid',
'gradle.properties',
),
path.join(
REPO_ROOT,
'packages',
'react-native',
'ReactAndroid',
'src',
'main',
'java',
'com',
'facebook',
'react',
'modules',
'systeminfo',
'ReactNativeVersion.java',
),
path.join(REPO_ROOT,
'packages',
'react-native',
'React',
'Base',
'RCTVersion.m',
),
path.join(
REPO_ROOT,
'packages',
'react-native',
'ReactCommon',
'cxxreact',
'ReactNativeVersion.h',
),
path.join(
REPO_ROOT,
'packages',
'react-native',
'Libraries',
'Core',
'ReactNativeVersion.js',
),
];
}
/**
* Custom afterAllProjectsVersioned hook for React Native macOS
* Updates React Native artifacts after all projects have been versioned
* @param {string} _cwd - Current working directory (unused)
* @param {object} _opts - Options object containing versioning information (unused)
* @returns {Promise<{changedFiles: string[], deletedFiles: string[]}>}
*/
const afterAllProjectsVersioned = async (_cwd, _opts) => {
const changedFiles = [];
try {
// Create the .rnm-publish file to indicate versioning has occurred
fs.writeFileSync(path.join(REPO_ROOT, '.rnm-publish'), '');
// Update React Native artifacts
const versionedFiles = await runSetVersion();
// Return the versioned files so Nx can track them
changedFiles.push(...versionedFiles);
console.log('✅ Updated React Native artifacts');
console.log('🏷️ Created .rnm-publish marker file');
} catch (error) {
console.error('Failed to update React Native artifacts:', error);
const errorMessage = error instanceof Error ? error.message : String(error);
console.error(`❌ Failed to update React Native artifacts: ${errorMessage}`);
throw error;
}
return {
changedFiles,
deletedFiles: [],
};
};
module.exports = JsVersionActions;
module.exports.default = JsVersionActions;
module.exports.afterAllProjectsVersioned = afterAllProjectsVersioned;