@internetderdinge/api 1.229.31 → 1.229.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/package.json
CHANGED
|
@@ -2,10 +2,12 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { execSync } from "node:child_process";
|
|
5
|
+
import dotenv from "dotenv";
|
|
5
6
|
import semver from "semver";
|
|
6
7
|
|
|
7
8
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
9
|
const repoRoot = path.resolve(__dirname, "..");
|
|
10
|
+
dotenv.config({ path: path.join(repoRoot, ".env") });
|
|
9
11
|
|
|
10
12
|
const args = process.argv.slice(2);
|
|
11
13
|
const shouldPublish = !args.includes("--no-publish");
|
|
@@ -44,12 +46,23 @@ const resolveNextVersion = (current, input) => {
|
|
|
44
46
|
);
|
|
45
47
|
};
|
|
46
48
|
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
const resolveUpdatePackagePaths = () => {
|
|
50
|
+
const updatePaths = process.env.UPDATE_PATHS?.split(",")
|
|
51
|
+
.map((value) => value.trim())
|
|
52
|
+
.filter(Boolean);
|
|
53
|
+
|
|
54
|
+
if (!updatePaths?.length) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
"UPDATE_PATHS must be set in .env to a comma-separated list of package.json paths.",
|
|
57
|
+
);
|
|
50
58
|
}
|
|
51
59
|
|
|
52
|
-
return
|
|
60
|
+
return updatePaths.map((updatePath) => {
|
|
61
|
+
const resolvedPath = path.resolve(repoRoot, updatePath);
|
|
62
|
+
return path.basename(resolvedPath) === "package.json"
|
|
63
|
+
? resolvedPath
|
|
64
|
+
: path.join(resolvedPath, "package.json");
|
|
65
|
+
});
|
|
53
66
|
};
|
|
54
67
|
|
|
55
68
|
const updateDependencyVersion = (
|
|
@@ -88,8 +101,9 @@ const updateDependencyVersion = (
|
|
|
88
101
|
currentDependencyVersion &&
|
|
89
102
|
currentDependencyVersion !== expectedVersion
|
|
90
103
|
) {
|
|
104
|
+
const packageName = path.basename(path.dirname(packageJsonPath));
|
|
91
105
|
throw new Error(
|
|
92
|
-
|
|
106
|
+
`${packageName} dependency is ${currentRange} (expected ${expectedVersion}). Update it before bumping.`,
|
|
93
107
|
);
|
|
94
108
|
}
|
|
95
109
|
|
|
@@ -117,34 +131,33 @@ if (!cleanedCurrent) {
|
|
|
117
131
|
}
|
|
118
132
|
|
|
119
133
|
const nextVersion = resolveNextVersion(currentVersion, versionInput);
|
|
134
|
+
const updatePackagePaths = resolveUpdatePackagePaths();
|
|
135
|
+
|
|
136
|
+
for (const updatePackagePath of updatePackagePaths) {
|
|
137
|
+
if (!fs.existsSync(updatePackagePath)) {
|
|
138
|
+
throw new Error(`Could not find package.json: ${updatePackagePath}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
120
141
|
|
|
121
142
|
apiPackage.version = nextVersion;
|
|
122
143
|
writeJson(apiPackagePath, apiPackage);
|
|
123
144
|
|
|
124
145
|
if (shouldPublish) {
|
|
146
|
+
// Always publish through npm, regardless of the package manager used to run this script.
|
|
125
147
|
execSync("npm publish", { cwd: repoRoot, stdio: "inherit" });
|
|
126
148
|
}
|
|
127
149
|
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const paperlessUpdate = updateDependencyVersion(
|
|
141
|
-
paperlessApiPath,
|
|
142
|
-
"@internetderdinge/api",
|
|
143
|
-
nextVersion,
|
|
144
|
-
cleanedCurrent,
|
|
145
|
-
);
|
|
150
|
+
const updates = updatePackagePaths.map((updatePackagePath) => ({
|
|
151
|
+
packageName: readJson(updatePackagePath).name,
|
|
152
|
+
...updateDependencyVersion(
|
|
153
|
+
updatePackagePath,
|
|
154
|
+
"@internetderdinge/api",
|
|
155
|
+
nextVersion,
|
|
156
|
+
cleanedCurrent,
|
|
157
|
+
),
|
|
158
|
+
}));
|
|
146
159
|
|
|
147
160
|
console.log(`Updated @internetderdinge/api to ${nextVersion}`);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
161
|
+
for (const update of updates) {
|
|
162
|
+
console.log(`${update.packageName}: ${update.previous} -> ${update.next}`);
|
|
163
|
+
}
|