@rollipop/init 1.0.0-alpha.31 → 1.0.0-alpha.32
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/dist/index.js +14 -8
- 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.32";
|
|
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
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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:
|
|
95
|
+
rollipop: version
|
|
90
96
|
};
|
|
91
97
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
|
|
92
98
|
}
|