@rollipop/init 1.0.0-beta.2 → 1.0.0-beta.4

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/README.md CHANGED
@@ -7,7 +7,7 @@ yarn dlx @rollipop/init@beta
7
7
  yarn install
8
8
  ```
9
9
 
10
- - Bare projects: logs `bare project detected`, adds the matching `rollipop` version, and configures `react-native.config.js`.
10
+ - Bare projects: logs `bare project detected`, adds the matching `rollipop` version, and configures `react-native.config.js` and `ios/.xcode.env` for Xcode bundle builds. The Xcode setup resolves local or hoisted `node_modules` without running Node before `.xcode.env.local` loads, preserves existing Node settings, and reports custom `CLI_PATH` configurations for manual setup. Projects without `ios` are skipped.
11
11
  - Expo projects: logs `expo project detected`, adds matching `rollipop` and `@rollipop/expo` versions, and registers the config plugin in `app.json` or `app.config.json` while preserving existing plugins. Dynamic JS/TS configuration is left unchanged with manual setup instructions.
12
12
 
13
13
  Expo detection uses the `expo` dependency in `package.json`, including prebuilt projects with native directories. See [Quick Start](https://rollipop.dev/docs/get-started/quick-start) or the [Expo guide](https://rollipop.dev/docs/experimental/expo) for setup and limitations.
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Visitor, parseSync } from "oxc-parser";
6
6
  //#region src/init.ts
7
7
  const { version } = {
8
8
  name: "@rollipop/init",
9
- version: "1.0.0-beta.2",
9
+ version: "1.0.0-beta.4",
10
10
  homepage: "https://github.com/rollipop-dev/rollipop#readme",
11
11
  bugs: { "url": "https://github.com/rollipop-dev/rollipop/issues" },
12
12
  license: "MIT",
@@ -39,6 +39,19 @@ const { version } = {
39
39
  };
40
40
  const RN_CONFIG_FILE = "react-native.config.js";
41
41
  const COMMANDS_REQUIRE = "require('rollipop/commands')";
42
+ const XCODE_CLI_PATH = "export CLI_PATH=\"$PROJECT_DIR/../node_modules/rollipop/bin/index.js\"";
43
+ const XCODE_ENV_SETUP = [
44
+ "# Resolve Rollipop without running Node before .xcode.env.local is loaded.",
45
+ "if [ -z \"${CLI_PATH:-}\" ]; then",
46
+ " ROLLIPOP_CLI_ROOT=\"$(cd \"$PROJECT_DIR/..\" && pwd)\"",
47
+ " while [ ! -f \"$ROLLIPOP_CLI_ROOT/node_modules/rollipop/bin/index.js\" ] && [ \"$ROLLIPOP_CLI_ROOT\" != / ]; do",
48
+ " ROLLIPOP_CLI_ROOT=\"${ROLLIPOP_CLI_ROOT%/*}\"",
49
+ " ROLLIPOP_CLI_ROOT=\"${ROLLIPOP_CLI_ROOT:-/}\"",
50
+ " done",
51
+ " export CLI_PATH=\"$ROLLIPOP_CLI_ROOT/node_modules/rollipop/bin/index.js\"",
52
+ " unset ROLLIPOP_CLI_ROOT",
53
+ "fi"
54
+ ].join("\n");
42
55
  function detectProject(cwd) {
43
56
  const packageJson = JSON.parse(fs.readFileSync(path.join(cwd, "package.json"), "utf8"));
44
57
  return packageJson.dependencies?.expo || packageJson.devDependencies?.expo ? "expo" : "bare";
@@ -95,6 +108,27 @@ function setupReactNativeConfig(cwd) {
95
108
  }
96
109
  }
97
110
  }
111
+ function setupXcodeEnv(cwd) {
112
+ const iosDir = path.join(cwd, "ios");
113
+ if (!fs.existsSync(iosDir)) return "skipped";
114
+ const filename = path.join(iosDir, ".xcode.env");
115
+ const exists = fs.existsSync(filename);
116
+ const content = exists ? fs.readFileSync(filename, "utf8") : "";
117
+ const localFilename = `${filename}.local`;
118
+ const local = fs.existsSync(localFilename) ? fs.readFileSync(localFilename, "utf8") : "";
119
+ const hasCliPath = (source) => source.split(/\r?\n/).some((line) => !line.trimStart().startsWith("#") && /\bCLI_PATH\b/.test(line));
120
+ const hasProjectOverride = fs.readdirSync(iosDir).some((entry) => {
121
+ const projectFile = path.join(iosDir, entry, "project.pbxproj");
122
+ return entry.endsWith(".xcodeproj") && fs.existsSync(projectFile) && /\bCLI_PATH\b/.test(fs.readFileSync(projectFile, "utf8"));
123
+ });
124
+ if (hasCliPath(local) || hasProjectOverride) return "manual-required";
125
+ const configured = content.includes(XCODE_ENV_SETUP) || content.split(/\r?\n/).includes(XCODE_CLI_PATH);
126
+ if (hasCliPath(content.replace(XCODE_ENV_SETUP, "").replace(XCODE_CLI_PATH, ""))) return "manual-required";
127
+ if (configured) return "already-configured";
128
+ const separator = content.length > 0 && !content.endsWith("\n") ? "\n" : "";
129
+ fs.writeFileSync(filename, `${content}${separator}${XCODE_ENV_SETUP}\n`);
130
+ return exists ? "updated" : "created";
131
+ }
98
132
  function analyzeConfig(content) {
99
133
  const { program, comments } = parseSync("react-native.config.js", content);
100
134
  let moduleExportsAssignment = null;
@@ -227,6 +261,28 @@ try {
227
261
  logger.error(projectType === "expo" ? "Expo setup failed" : "React Native CLI setup failed", error);
228
262
  failed ||= true;
229
263
  }
264
+ if (projectType === "bare") try {
265
+ const status = setupXcodeEnv(cwd);
266
+ switch (status) {
267
+ case "created":
268
+ case "updated":
269
+ logger.success(`${status === "created" ? "Created" : "Updated"} ${pc.bold("ios/.xcode.env")}`);
270
+ break;
271
+ case "already-configured":
272
+ logger.info(`${pc.bold("ios/.xcode.env")} already configured`);
273
+ break;
274
+ case "skipped":
275
+ logger.info("No ios directory; skipped Xcode bundle setup");
276
+ break;
277
+ case "manual-required":
278
+ hasWarning = true;
279
+ logger.warn("Existing CLI_PATH configuration requires manual Xcode bundle setup");
280
+ console.log(` Point ${pc.bold("CLI_PATH")} to ${pc.green("rollipop/bin/index.js")} in your Xcode environment or bundle phase, keeping your Node setup.`);
281
+ }
282
+ } catch (error) {
283
+ logger.error("Xcode bundle setup failed", error);
284
+ failed ||= true;
285
+ }
230
286
  if (hasWarning || failed) console.log();
231
287
  try {
232
288
  const dependencies = setupPackage(cwd);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollipop/init",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.4",
4
4
  "homepage": "https://github.com/rollipop-dev/rollipop#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/rollipop-dev/rollipop/issues"