@rollipop/init 1.0.0-alpha.31 → 1.0.0-alpha.33

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.
Files changed (2) hide show
  1. package/dist/index.js +14 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2,6 +2,9 @@ import pc from "picocolors";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { Visitor, parseSync } from "oxc-parser";
5
+ //#region package.json
6
+ var version = "1.0.0-alpha.33";
7
+ //#endregion
5
8
  //#region src/init.ts
6
9
  const RN_CONFIG_FILE = "react-native.config.js";
7
10
  const COMMANDS_REQUIRE = "require('rollipop/commands')";
@@ -25,7 +28,7 @@ function setupReactNativeConfig(cwd) {
25
28
  }
26
29
  }
27
30
  function analyzeConfig(content) {
28
- const { program } = parseSync("react-native.config.js", content);
31
+ const { program, comments } = parseSync("react-native.config.js", content);
29
32
  let moduleExportsAssignment = null;
30
33
  new Visitor({ AssignmentExpression(node) {
31
34
  if (isModuleExports(node)) moduleExportsAssignment = node;
@@ -43,12 +46,15 @@ function analyzeConfig(content) {
43
46
  const lastProp = properties[properties.length - 1];
44
47
  const closingBrace = objectExpr.end - 1;
45
48
  if (lastProp) {
46
- const commaIndex = content.substring(lastProp.end, closingBrace).indexOf(",");
47
- if (commaIndex !== -1) return {
48
- status: "injectable",
49
- insertOffset: lastProp.end + commaIndex + 1,
50
- needsComma: false
51
- };
49
+ const afterLastProp = content.substring(lastProp.end, closingBrace);
50
+ for (const match of afterLastProp.matchAll(/,/g)) {
51
+ const offset = lastProp.end + match.index;
52
+ if (!comments.some((comment) => comment.start <= offset && offset < comment.end)) return {
53
+ status: "injectable",
54
+ insertOffset: offset + 1,
55
+ needsComma: false
56
+ };
57
+ }
52
58
  return {
53
59
  status: "injectable",
54
60
  insertOffset: lastProp.end,
@@ -86,7 +92,7 @@ function setupPackage(cwd) {
86
92
  const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
87
93
  packageJson.devDependencies = {
88
94
  ...packageJson.devDependencies,
89
- rollipop: "latest"
95
+ rollipop: version
90
96
  };
91
97
  fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
92
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rollipop/init",
3
- "version": "1.0.0-alpha.31",
3
+ "version": "1.0.0-alpha.33",
4
4
  "homepage": "https://github.com/rollipop-dev/rollipop#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/rollipop-dev/rollipop/issues"