-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathupdate-create-refine-app-registry.js
63 lines (51 loc) · 1.46 KB
/
update-create-refine-app-registry.js
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
const fs = require("fs");
const path = require("path");
const packageJsonPath = path.join(
process.cwd(),
"packages/create-refine-app/package.json",
);
function addRegistry() {
try {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
packageJson.publishConfig = {
...packageJson.publishConfig,
registry: "https://registry.refine.dev",
};
fs.writeFileSync(
packageJsonPath,
`${JSON.stringify(packageJson, null, 2)}\n`,
);
console.log("Registry configuration added successfully.");
} catch (error) {
console.error("Error adding registry:", error);
process.exit(1);
}
}
function removeRegistry() {
try {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
if (packageJson.publishConfig) {
delete packageJson.publishConfig.registry;
if (Object.keys(packageJson.publishConfig).length === 0) {
delete packageJson.publishConfig;
}
}
fs.writeFileSync(
packageJsonPath,
`${JSON.stringify(packageJson, null, 2)}\n`,
);
console.log("Registry configuration removed successfully.");
} catch (error) {
console.error("Error removing registry:", error);
process.exit(1);
}
}
const action = process.argv[2];
if (action === "add") {
addRegistry();
} else if (action === "remove") {
removeRegistry();
} else {
console.error("Please specify either 'add' or 'remove' as an argument");
process.exit(1);
}