react-native-update-cli 2.3.1 → 2.4.0

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/lib/bundle.js CHANGED
@@ -109,15 +109,28 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
109
109
  let usingExpo = false;
110
110
  const getExpoCli = ()=>{
111
111
  try {
112
+ const searchPaths = [
113
+ process.cwd()
114
+ ];
115
+ // 尝试添加 expo 包的路径作为额外的搜索路径
116
+ try {
117
+ const expoPath = require.resolve('expo/package.json', {
118
+ paths: [
119
+ process.cwd()
120
+ ]
121
+ });
122
+ // 获取 expo 包的目录路径
123
+ const expoDir = expoPath.replace(/\/package\.json$/, '');
124
+ searchPaths.push(expoDir);
125
+ } catch (e) {
126
+ // expo 包不存在,忽略
127
+ }
128
+ // 尝试从搜索路径中解析 @expo/cli
112
129
  cliPath = require.resolve('@expo/cli', {
113
- paths: [
114
- process.cwd()
115
- ]
130
+ paths: searchPaths
116
131
  });
117
132
  const expoCliVersion = JSON.parse(_fsextra.readFileSync(require.resolve('@expo/cli/package.json', {
118
- paths: [
119
- process.cwd()
120
- ]
133
+ paths: searchPaths
121
134
  })).toString()).version;
122
135
  // expo cli 0.10.17 (expo 49) 开始支持 bundle:embed
123
136
  if ((0, _compareversions.satisfies)(expoCliVersion, '>= 0.10.17')) {
package/lib/versions.js CHANGED
@@ -105,17 +105,6 @@ const bindVersionToPackages = async ({ appId, versionId, pkgs, rollout, dryRun }
105
105
  console.log(_chalk.default.yellow((0, _i18n.t)('dryRun')));
106
106
  }
107
107
  if (rollout !== undefined) {
108
- const rolloutConfig = {};
109
- for (const pkg of pkgs){
110
- rolloutConfig[pkg.name] = rollout;
111
- }
112
- if (!dryRun) {
113
- await (0, _api.put)(`/app/${appId}/version/${versionId}`, {
114
- config: {
115
- rollout: rolloutConfig
116
- }
117
- });
118
- }
119
108
  console.log(`${(0, _i18n.t)('rolloutConfigSet', {
120
109
  versions: pkgs.map((pkg)=>pkg.name).join(', '),
121
110
  rollout: rollout
@@ -123,8 +112,10 @@ const bindVersionToPackages = async ({ appId, versionId, pkgs, rollout, dryRun }
123
112
  }
124
113
  for (const pkg of pkgs){
125
114
  if (!dryRun) {
126
- await (0, _api.put)(`/app/${appId}/package/${pkg.id}`, {
127
- versionId
115
+ await (0, _api.post)(`/app/${appId}/binding`, {
116
+ versionId,
117
+ rollout,
118
+ packageId: pkg.id
128
119
  });
129
120
  }
130
121
  console.log(`${(0, _i18n.t)('versionBind', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/bundle.ts CHANGED
@@ -85,14 +85,30 @@ async function runReactNativeBundleCommand({
85
85
 
86
86
  const getExpoCli = () => {
87
87
  try {
88
+ const searchPaths = [process.cwd()];
89
+
90
+ // 尝试添加 expo 包的路径作为额外的搜索路径
91
+ try {
92
+ const expoPath = require.resolve('expo/package.json', {
93
+ paths: [process.cwd()],
94
+ });
95
+ // 获取 expo 包的目录路径
96
+ const expoDir = expoPath.replace(/\/package\.json$/, '');
97
+ searchPaths.push(expoDir);
98
+ } catch {
99
+ // expo 包不存在,忽略
100
+ }
101
+
102
+ // 尝试从搜索路径中解析 @expo/cli
88
103
  cliPath = require.resolve('@expo/cli', {
89
- paths: [process.cwd()],
104
+ paths: searchPaths,
90
105
  });
106
+
91
107
  const expoCliVersion = JSON.parse(
92
108
  fs
93
109
  .readFileSync(
94
110
  require.resolve('@expo/cli/package.json', {
95
- paths: [process.cwd()],
111
+ paths: searchPaths,
96
112
  }),
97
113
  )
98
114
  .toString(),
package/src/versions.ts CHANGED
@@ -122,17 +122,6 @@ export const bindVersionToPackages = async ({
122
122
  console.log(chalk.yellow(t('dryRun')));
123
123
  }
124
124
  if (rollout !== undefined) {
125
- const rolloutConfig: Record<string, number> = {};
126
- for (const pkg of pkgs) {
127
- rolloutConfig[pkg.name] = rollout;
128
- }
129
- if (!dryRun) {
130
- await put(`/app/${appId}/version/${versionId}`, {
131
- config: {
132
- rollout: rolloutConfig,
133
- },
134
- });
135
- }
136
125
  console.log(
137
126
  `${t('rolloutConfigSet', {
138
127
  versions: pkgs.map((pkg: Package) => pkg.name).join(', '),
@@ -142,8 +131,10 @@ export const bindVersionToPackages = async ({
142
131
  }
143
132
  for (const pkg of pkgs) {
144
133
  if (!dryRun) {
145
- await put(`/app/${appId}/package/${pkg.id}`, {
134
+ await post(`/app/${appId}/binding`, {
146
135
  versionId,
136
+ rollout,
137
+ packageId: pkg.id,
147
138
  });
148
139
  }
149
140
  console.log(