pubm 0.1.5 → 0.1.6
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/bin/cli.js +221 -170
- package/dist/index.cjs +241 -190
- package/dist/index.js +238 -187
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4854,9 +4854,71 @@ function createListr(...args) {
|
|
|
4854
4854
|
}
|
|
4855
4855
|
|
|
4856
4856
|
// src/utils/package.ts
|
|
4857
|
+
var import_promises3 = require("fs/promises");
|
|
4858
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
4859
|
+
var import_node_process5 = __toESM(require("process"), 1);
|
|
4860
|
+
|
|
4861
|
+
// src/ecosystem/rust.ts
|
|
4857
4862
|
var import_promises2 = require("fs/promises");
|
|
4858
4863
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
4859
|
-
var
|
|
4864
|
+
var import_smol_toml = require("smol-toml");
|
|
4865
|
+
|
|
4866
|
+
// src/ecosystem/ecosystem.ts
|
|
4867
|
+
var Ecosystem = class {
|
|
4868
|
+
constructor(packagePath) {
|
|
4869
|
+
this.packagePath = packagePath;
|
|
4870
|
+
}
|
|
4871
|
+
};
|
|
4872
|
+
|
|
4873
|
+
// src/ecosystem/rust.ts
|
|
4874
|
+
var RustEcosystem = class extends Ecosystem {
|
|
4875
|
+
static async detect(packagePath) {
|
|
4876
|
+
try {
|
|
4877
|
+
return (await (0, import_promises2.stat)(import_node_path2.default.join(packagePath, "Cargo.toml"))).isFile();
|
|
4878
|
+
} catch {
|
|
4879
|
+
return false;
|
|
4880
|
+
}
|
|
4881
|
+
}
|
|
4882
|
+
async readCargoToml() {
|
|
4883
|
+
const raw = await (0, import_promises2.readFile)(
|
|
4884
|
+
import_node_path2.default.join(this.packagePath, "Cargo.toml"),
|
|
4885
|
+
"utf-8"
|
|
4886
|
+
);
|
|
4887
|
+
return (0, import_smol_toml.parse)(raw);
|
|
4888
|
+
}
|
|
4889
|
+
async packageName() {
|
|
4890
|
+
const cargo = await this.readCargoToml();
|
|
4891
|
+
const pkg = cargo.package;
|
|
4892
|
+
return pkg.name;
|
|
4893
|
+
}
|
|
4894
|
+
async readVersion() {
|
|
4895
|
+
const cargo = await this.readCargoToml();
|
|
4896
|
+
const pkg = cargo.package;
|
|
4897
|
+
return pkg.version;
|
|
4898
|
+
}
|
|
4899
|
+
async writeVersion(newVersion) {
|
|
4900
|
+
const filePath = import_node_path2.default.join(this.packagePath, "Cargo.toml");
|
|
4901
|
+
const raw = await (0, import_promises2.readFile)(filePath, "utf-8");
|
|
4902
|
+
const cargo = (0, import_smol_toml.parse)(raw);
|
|
4903
|
+
const pkg = cargo.package;
|
|
4904
|
+
pkg.version = newVersion;
|
|
4905
|
+
await (0, import_promises2.writeFile)(filePath, (0, import_smol_toml.stringify)(cargo));
|
|
4906
|
+
}
|
|
4907
|
+
manifestFiles() {
|
|
4908
|
+
return ["Cargo.toml"];
|
|
4909
|
+
}
|
|
4910
|
+
defaultTestCommand() {
|
|
4911
|
+
return "cargo test";
|
|
4912
|
+
}
|
|
4913
|
+
defaultBuildCommand() {
|
|
4914
|
+
return "cargo build --release";
|
|
4915
|
+
}
|
|
4916
|
+
supportedRegistries() {
|
|
4917
|
+
return ["crates"];
|
|
4918
|
+
}
|
|
4919
|
+
};
|
|
4920
|
+
|
|
4921
|
+
// src/utils/package.ts
|
|
4860
4922
|
var cachedPackageJson = {};
|
|
4861
4923
|
var cachedJsrJson = {};
|
|
4862
4924
|
function patchCachedJsrJson(contents, { cwd = import_node_process5.default.cwd() } = {}) {
|
|
@@ -4865,16 +4927,16 @@ function patchCachedJsrJson(contents, { cwd = import_node_process5.default.cwd()
|
|
|
4865
4927
|
async function findOutFile(file, { cwd = import_node_process5.default.cwd() } = {}) {
|
|
4866
4928
|
let directory = cwd;
|
|
4867
4929
|
let filePath = "";
|
|
4868
|
-
const { root } =
|
|
4930
|
+
const { root } = import_node_path3.default.parse(cwd);
|
|
4869
4931
|
while (directory) {
|
|
4870
|
-
filePath =
|
|
4932
|
+
filePath = import_node_path3.default.join(directory, file);
|
|
4871
4933
|
try {
|
|
4872
|
-
if ((await (0,
|
|
4934
|
+
if ((await (0, import_promises3.stat)(filePath)).isFile()) {
|
|
4873
4935
|
break;
|
|
4874
4936
|
}
|
|
4875
4937
|
} catch {
|
|
4876
4938
|
}
|
|
4877
|
-
directory =
|
|
4939
|
+
directory = import_node_path3.default.dirname(directory);
|
|
4878
4940
|
if (directory === root) return null;
|
|
4879
4941
|
}
|
|
4880
4942
|
return filePath;
|
|
@@ -4886,7 +4948,7 @@ async function getPackageJson({
|
|
|
4886
4948
|
if (cachedPackageJson[cwd]) return cachedPackageJson[cwd];
|
|
4887
4949
|
try {
|
|
4888
4950
|
const packageJsonPath = await findOutFile("package.json");
|
|
4889
|
-
const raw = packageJsonPath && (await (0,
|
|
4951
|
+
const raw = packageJsonPath && (await (0, import_promises3.readFile)(packageJsonPath)).toString();
|
|
4890
4952
|
if (!raw) {
|
|
4891
4953
|
if (!fallbackJsr) {
|
|
4892
4954
|
throw new Error(
|
|
@@ -4919,7 +4981,7 @@ async function getJsrJson({
|
|
|
4919
4981
|
if (cachedJsrJson[cwd]) return cachedJsrJson[cwd];
|
|
4920
4982
|
try {
|
|
4921
4983
|
const jsrJsonPath = await findOutFile("jsr.json");
|
|
4922
|
-
const raw = jsrJsonPath && (await (0,
|
|
4984
|
+
const raw = jsrJsonPath && (await (0, import_promises3.readFile)(jsrJsonPath)).toString();
|
|
4923
4985
|
if (!raw) {
|
|
4924
4986
|
if (!fallbackPackage) {
|
|
4925
4987
|
throw new Error(
|
|
@@ -5003,14 +5065,14 @@ async function version({ cwd = import_node_process5.default.cwd() } = {}) {
|
|
|
5003
5065
|
return version2;
|
|
5004
5066
|
}
|
|
5005
5067
|
var versionRegex = /("version"\s*:\s*")[^"]*(")/;
|
|
5006
|
-
async function replaceVersion(version2) {
|
|
5068
|
+
async function replaceVersion(version2, packages) {
|
|
5007
5069
|
const results = await Promise.all([
|
|
5008
5070
|
(async () => {
|
|
5009
5071
|
const packageJsonPath = await findOutFile("package.json");
|
|
5010
5072
|
if (!packageJsonPath) return void 0;
|
|
5011
|
-
const packageJson = (await (0,
|
|
5073
|
+
const packageJson = (await (0, import_promises3.readFile)(packageJsonPath)).toString();
|
|
5012
5074
|
try {
|
|
5013
|
-
await (0,
|
|
5075
|
+
await (0, import_promises3.writeFile)(
|
|
5014
5076
|
packageJsonPath,
|
|
5015
5077
|
packageJson.replace(versionRegex, `$1${version2}$2`)
|
|
5016
5078
|
);
|
|
@@ -5025,9 +5087,9 @@ async function replaceVersion(version2) {
|
|
|
5025
5087
|
(async () => {
|
|
5026
5088
|
const jsrJsonPath = await findOutFile("jsr.json");
|
|
5027
5089
|
if (!jsrJsonPath) return void 0;
|
|
5028
|
-
const jsrJson = (await (0,
|
|
5090
|
+
const jsrJson = (await (0, import_promises3.readFile)(jsrJsonPath)).toString();
|
|
5029
5091
|
try {
|
|
5030
|
-
await (0,
|
|
5092
|
+
await (0, import_promises3.writeFile)(
|
|
5031
5093
|
jsrJsonPath,
|
|
5032
5094
|
jsrJson.replace(versionRegex, `$1${version2}$2`)
|
|
5033
5095
|
);
|
|
@@ -5038,7 +5100,19 @@ async function replaceVersion(version2) {
|
|
|
5038
5100
|
);
|
|
5039
5101
|
}
|
|
5040
5102
|
return "jsr.json";
|
|
5041
|
-
})()
|
|
5103
|
+
})(),
|
|
5104
|
+
...(packages ?? []).filter((pkg) => pkg.registries.includes("crates")).map(async (pkg) => {
|
|
5105
|
+
const eco = new RustEcosystem(import_node_path3.default.resolve(pkg.path));
|
|
5106
|
+
try {
|
|
5107
|
+
await eco.writeVersion(version2);
|
|
5108
|
+
} catch (error) {
|
|
5109
|
+
throw new AbstractError(
|
|
5110
|
+
`Failed to write version to Cargo.toml at ${pkg.path}: ${error instanceof Error ? error.message : error}`,
|
|
5111
|
+
{ cause: error }
|
|
5112
|
+
);
|
|
5113
|
+
}
|
|
5114
|
+
return import_node_path3.default.join(pkg.path, "Cargo.toml");
|
|
5115
|
+
})
|
|
5042
5116
|
]);
|
|
5043
5117
|
return results.filter((v) => v);
|
|
5044
5118
|
}
|
|
@@ -5059,67 +5133,26 @@ async function getPackageManager() {
|
|
|
5059
5133
|
return "npm";
|
|
5060
5134
|
}
|
|
5061
5135
|
|
|
5062
|
-
// src/
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
}
|
|
5073
|
-
|
|
5074
|
-
// src/ecosystem/rust.ts
|
|
5075
|
-
var RustEcosystem = class extends Ecosystem {
|
|
5076
|
-
static async detect(packagePath) {
|
|
5077
|
-
try {
|
|
5078
|
-
return (await (0, import_promises3.stat)(import_node_path3.default.join(packagePath, "Cargo.toml"))).isFile();
|
|
5079
|
-
} catch {
|
|
5080
|
-
return false;
|
|
5136
|
+
// src/utils/registries.ts
|
|
5137
|
+
function collectRegistries(ctx) {
|
|
5138
|
+
if (ctx.packages?.length) {
|
|
5139
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5140
|
+
const result = [];
|
|
5141
|
+
for (const pkg of ctx.packages) {
|
|
5142
|
+
for (const reg of pkg.registries) {
|
|
5143
|
+
if (!seen.has(reg)) {
|
|
5144
|
+
seen.add(reg);
|
|
5145
|
+
result.push(reg);
|
|
5146
|
+
}
|
|
5147
|
+
}
|
|
5081
5148
|
}
|
|
5149
|
+
return result;
|
|
5082
5150
|
}
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
import_node_path3.default.join(this.packagePath, "Cargo.toml"),
|
|
5086
|
-
"utf-8"
|
|
5087
|
-
);
|
|
5088
|
-
return (0, import_smol_toml.parse)(raw);
|
|
5089
|
-
}
|
|
5090
|
-
async packageName() {
|
|
5091
|
-
const cargo = await this.readCargoToml();
|
|
5092
|
-
const pkg = cargo.package;
|
|
5093
|
-
return pkg.name;
|
|
5094
|
-
}
|
|
5095
|
-
async readVersion() {
|
|
5096
|
-
const cargo = await this.readCargoToml();
|
|
5097
|
-
const pkg = cargo.package;
|
|
5098
|
-
return pkg.version;
|
|
5099
|
-
}
|
|
5100
|
-
async writeVersion(newVersion) {
|
|
5101
|
-
const filePath = import_node_path3.default.join(this.packagePath, "Cargo.toml");
|
|
5102
|
-
const raw = await (0, import_promises3.readFile)(filePath, "utf-8");
|
|
5103
|
-
const cargo = (0, import_smol_toml.parse)(raw);
|
|
5104
|
-
const pkg = cargo.package;
|
|
5105
|
-
pkg.version = newVersion;
|
|
5106
|
-
await (0, import_promises3.writeFile)(filePath, (0, import_smol_toml.stringify)(cargo));
|
|
5107
|
-
}
|
|
5108
|
-
manifestFiles() {
|
|
5109
|
-
return ["Cargo.toml"];
|
|
5110
|
-
}
|
|
5111
|
-
defaultTestCommand() {
|
|
5112
|
-
return "cargo test";
|
|
5113
|
-
}
|
|
5114
|
-
defaultBuildCommand() {
|
|
5115
|
-
return "cargo build --release";
|
|
5116
|
-
}
|
|
5117
|
-
supportedRegistries() {
|
|
5118
|
-
return ["crates"];
|
|
5119
|
-
}
|
|
5120
|
-
};
|
|
5151
|
+
return ctx.registries;
|
|
5152
|
+
}
|
|
5121
5153
|
|
|
5122
5154
|
// src/registry/crates.ts
|
|
5155
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
5123
5156
|
var import_tinyexec2 = require("tinyexec");
|
|
5124
5157
|
|
|
5125
5158
|
// src/registry/registry.ts
|
|
@@ -5193,9 +5226,13 @@ var CratesRegistry = class extends Registry {
|
|
|
5193
5226
|
);
|
|
5194
5227
|
}
|
|
5195
5228
|
}
|
|
5196
|
-
async publish() {
|
|
5229
|
+
async publish(manifestDir) {
|
|
5197
5230
|
try {
|
|
5198
|
-
|
|
5231
|
+
const args = ["publish"];
|
|
5232
|
+
if (manifestDir) {
|
|
5233
|
+
args.push("--manifest-path", import_node_path4.default.join(manifestDir, "Cargo.toml"));
|
|
5234
|
+
}
|
|
5235
|
+
await (0, import_tinyexec2.exec)("cargo", args, { throwOnError: true });
|
|
5199
5236
|
return true;
|
|
5200
5237
|
} catch (error) {
|
|
5201
5238
|
throw new CratesError("Failed to run `cargo publish`", {
|
|
@@ -5251,35 +5288,43 @@ var CratesError2 = class extends AbstractError {
|
|
|
5251
5288
|
this.stack = "";
|
|
5252
5289
|
}
|
|
5253
5290
|
};
|
|
5254
|
-
async function getCrateName() {
|
|
5255
|
-
const eco = new RustEcosystem(process.cwd());
|
|
5291
|
+
async function getCrateName(packagePath) {
|
|
5292
|
+
const eco = new RustEcosystem(packagePath ?? process.cwd());
|
|
5256
5293
|
return await eco.packageName();
|
|
5257
5294
|
}
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5295
|
+
function createCratesAvailableCheckTask(packagePath) {
|
|
5296
|
+
const label = packagePath ? ` (${packagePath})` : "";
|
|
5297
|
+
return {
|
|
5298
|
+
title: `Checking crates.io availability${label}`,
|
|
5299
|
+
task: async () => {
|
|
5300
|
+
const packageName = await getCrateName(packagePath);
|
|
5301
|
+
const registry = new CratesRegistry(packageName);
|
|
5302
|
+
if (!await registry.isInstalled()) {
|
|
5303
|
+
throw new CratesError2(
|
|
5304
|
+
"cargo is not installed. Please install Rust toolchain to proceed."
|
|
5305
|
+
);
|
|
5306
|
+
}
|
|
5307
|
+
if (!await registry.hasPermission()) {
|
|
5308
|
+
throw new CratesError2(
|
|
5309
|
+
"No crates.io credentials found. Run `cargo login` or set CARGO_REGISTRY_TOKEN."
|
|
5310
|
+
);
|
|
5311
|
+
}
|
|
5267
5312
|
}
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5313
|
+
};
|
|
5314
|
+
}
|
|
5315
|
+
function createCratesPublishTask(packagePath) {
|
|
5316
|
+
const label = packagePath ? ` (${packagePath})` : "";
|
|
5317
|
+
return {
|
|
5318
|
+
title: `Publishing to crates.io${label}`,
|
|
5319
|
+
task: async () => {
|
|
5320
|
+
const packageName = await getCrateName(packagePath);
|
|
5321
|
+
const registry = new CratesRegistry(packageName);
|
|
5322
|
+
await registry.publish(packagePath);
|
|
5272
5323
|
}
|
|
5273
|
-
}
|
|
5274
|
-
}
|
|
5275
|
-
var
|
|
5276
|
-
|
|
5277
|
-
task: async () => {
|
|
5278
|
-
const packageName = await getCrateName();
|
|
5279
|
-
const registry = new CratesRegistry(packageName);
|
|
5280
|
-
await registry.publish();
|
|
5281
|
-
}
|
|
5282
|
-
};
|
|
5324
|
+
};
|
|
5325
|
+
}
|
|
5326
|
+
var cratesAvailableCheckTasks = createCratesAvailableCheckTask();
|
|
5327
|
+
var cratesPublishTasks = createCratesPublishTask();
|
|
5283
5328
|
|
|
5284
5329
|
// src/tasks/jsr.ts
|
|
5285
5330
|
var import_node_process6 = __toESM(require("process"), 1);
|
|
@@ -5292,7 +5337,7 @@ var import_tinyexec3 = require("tinyexec");
|
|
|
5292
5337
|
// src/utils/db.ts
|
|
5293
5338
|
var import_node_crypto = require("crypto");
|
|
5294
5339
|
var import_node_fs = require("fs");
|
|
5295
|
-
var
|
|
5340
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
5296
5341
|
var import_meta = {};
|
|
5297
5342
|
var a = "aes-256-cbc";
|
|
5298
5343
|
var n = (0, import_node_fs.statSync)(import_meta.dirname);
|
|
@@ -5308,7 +5353,7 @@ function d(g, h) {
|
|
|
5308
5353
|
}
|
|
5309
5354
|
var Db = class {
|
|
5310
5355
|
constructor() {
|
|
5311
|
-
__publicField(this, "path",
|
|
5356
|
+
__publicField(this, "path", import_node_path5.default.resolve(import_meta.dirname, ".pubm"));
|
|
5312
5357
|
try {
|
|
5313
5358
|
if (!(0, import_node_fs.statSync)(this.path).isDirectory()) {
|
|
5314
5359
|
(0, import_node_fs.mkdirSync)(this.path);
|
|
@@ -5326,7 +5371,7 @@ var Db = class {
|
|
|
5326
5371
|
set(field, value) {
|
|
5327
5372
|
try {
|
|
5328
5373
|
(0, import_node_fs.writeFileSync)(
|
|
5329
|
-
|
|
5374
|
+
import_node_path5.default.resolve(
|
|
5330
5375
|
this.path,
|
|
5331
5376
|
Buffer.from(e(field, field)).toString("base64")
|
|
5332
5377
|
),
|
|
@@ -5340,7 +5385,7 @@ var Db = class {
|
|
|
5340
5385
|
}
|
|
5341
5386
|
}
|
|
5342
5387
|
get(field) {
|
|
5343
|
-
const filePath =
|
|
5388
|
+
const filePath = import_node_path5.default.resolve(
|
|
5344
5389
|
this.path,
|
|
5345
5390
|
Buffer.from(e(field, field)).toString("base64")
|
|
5346
5391
|
);
|
|
@@ -6178,9 +6223,7 @@ var npmAvailableCheckTasks = {
|
|
|
6178
6223
|
child.stderr?.on("data", onData);
|
|
6179
6224
|
child.on(
|
|
6180
6225
|
"close",
|
|
6181
|
-
(code) => code === 0 ? resolve() : reject(
|
|
6182
|
-
new Error(`npm login exited with code ${code}`)
|
|
6183
|
-
)
|
|
6226
|
+
(code) => code === 0 ? resolve() : reject(new Error(`npm login exited with code ${code}`))
|
|
6184
6227
|
);
|
|
6185
6228
|
child.on("error", reject);
|
|
6186
6229
|
});
|
|
@@ -6484,7 +6527,7 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
6484
6527
|
{
|
|
6485
6528
|
title: "Ping registries",
|
|
6486
6529
|
task: (ctx, parentTask2) => parentTask2.newListr(
|
|
6487
|
-
ctx.
|
|
6530
|
+
collectRegistries(ctx).map((registryKey) => ({
|
|
6488
6531
|
title: `Ping to ${registryKey}`,
|
|
6489
6532
|
task: async () => {
|
|
6490
6533
|
const registry = await getRegistry(registryKey);
|
|
@@ -6501,7 +6544,9 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
6501
6544
|
task: async (_2, parentTask2) => parentTask2.newListr(
|
|
6502
6545
|
[
|
|
6503
6546
|
{
|
|
6504
|
-
enabled: (ctx) => ctx.
|
|
6547
|
+
enabled: (ctx) => collectRegistries(ctx).some(
|
|
6548
|
+
(registry) => registry !== "jsr"
|
|
6549
|
+
),
|
|
6505
6550
|
title: "Verifying if npm are installed",
|
|
6506
6551
|
task: async () => {
|
|
6507
6552
|
const npm = await npmRegistry();
|
|
@@ -6513,7 +6558,9 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
6513
6558
|
}
|
|
6514
6559
|
},
|
|
6515
6560
|
{
|
|
6516
|
-
enabled: (ctx) => ctx.
|
|
6561
|
+
enabled: (ctx) => collectRegistries(ctx).some(
|
|
6562
|
+
(registry) => registry === "jsr"
|
|
6563
|
+
),
|
|
6517
6564
|
title: "Verifying if jsr are installed",
|
|
6518
6565
|
task: async (_3, task) => {
|
|
6519
6566
|
const jsr = await jsrRegistry();
|
|
@@ -6544,7 +6591,7 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
6544
6591
|
},
|
|
6545
6592
|
{
|
|
6546
6593
|
title: "Checking if test and build scripts exist",
|
|
6547
|
-
skip: (ctx) => !needsPackageScripts(ctx
|
|
6594
|
+
skip: (ctx) => !needsPackageScripts(collectRegistries(ctx)),
|
|
6548
6595
|
task: async (ctx) => {
|
|
6549
6596
|
const { scripts } = await getPackageJson();
|
|
6550
6597
|
const errors = [];
|
|
@@ -6572,23 +6619,42 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
6572
6619
|
},
|
|
6573
6620
|
{
|
|
6574
6621
|
title: "Checking available registries for publishing",
|
|
6575
|
-
task: (ctx, parentTask2) =>
|
|
6576
|
-
ctx.
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6622
|
+
task: (ctx, parentTask2) => {
|
|
6623
|
+
if (ctx.packages?.length) {
|
|
6624
|
+
const tasks = ctx.packages.flatMap(
|
|
6625
|
+
(pkg) => pkg.registries.map((registryKey) => {
|
|
6626
|
+
switch (registryKey) {
|
|
6627
|
+
case "npm":
|
|
6628
|
+
return npmAvailableCheckTasks;
|
|
6629
|
+
case "jsr":
|
|
6630
|
+
return jsrAvailableCheckTasks;
|
|
6631
|
+
case "crates":
|
|
6632
|
+
return createCratesAvailableCheckTask(pkg.path);
|
|
6633
|
+
default:
|
|
6634
|
+
return npmAvailableCheckTasks;
|
|
6635
|
+
}
|
|
6636
|
+
})
|
|
6637
|
+
);
|
|
6638
|
+
return parentTask2.newListr(tasks, { concurrent: true });
|
|
6590
6639
|
}
|
|
6591
|
-
|
|
6640
|
+
return parentTask2.newListr(
|
|
6641
|
+
collectRegistries(ctx).map((registryKey) => {
|
|
6642
|
+
switch (registryKey) {
|
|
6643
|
+
case "npm":
|
|
6644
|
+
return npmAvailableCheckTasks;
|
|
6645
|
+
case "jsr":
|
|
6646
|
+
return jsrAvailableCheckTasks;
|
|
6647
|
+
case "crates":
|
|
6648
|
+
return cratesAvailableCheckTasks;
|
|
6649
|
+
default:
|
|
6650
|
+
return npmAvailableCheckTasks;
|
|
6651
|
+
}
|
|
6652
|
+
}),
|
|
6653
|
+
{
|
|
6654
|
+
concurrent: true
|
|
6655
|
+
}
|
|
6656
|
+
);
|
|
6657
|
+
}
|
|
6592
6658
|
}
|
|
6593
6659
|
],
|
|
6594
6660
|
{
|
|
@@ -6600,21 +6666,27 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
6600
6666
|
// src/tasks/runner.ts
|
|
6601
6667
|
var { open: open3 } = import_promise_spawn3.default;
|
|
6602
6668
|
var { prerelease } = import_semver3.default;
|
|
6603
|
-
function
|
|
6669
|
+
function registryTask(registry) {
|
|
6670
|
+
switch (registry) {
|
|
6671
|
+
case "npm":
|
|
6672
|
+
return npmPublishTasks;
|
|
6673
|
+
case "jsr":
|
|
6674
|
+
return jsrPublishTasks;
|
|
6675
|
+
case "crates":
|
|
6676
|
+
return cratesPublishTasks;
|
|
6677
|
+
default:
|
|
6678
|
+
return npmPublishTasks;
|
|
6679
|
+
}
|
|
6680
|
+
}
|
|
6681
|
+
function collectPublishTasks(ctx) {
|
|
6604
6682
|
if (ctx.packages?.length) {
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
seen.add(reg);
|
|
6611
|
-
result.push(reg);
|
|
6612
|
-
}
|
|
6613
|
-
}
|
|
6614
|
-
}
|
|
6615
|
-
return result;
|
|
6683
|
+
return ctx.packages.flatMap(
|
|
6684
|
+
(pkg) => pkg.registries.map(
|
|
6685
|
+
(reg) => reg === "crates" ? createCratesPublishTask(pkg.path) : registryTask(reg)
|
|
6686
|
+
)
|
|
6687
|
+
);
|
|
6616
6688
|
}
|
|
6617
|
-
return ctx.
|
|
6689
|
+
return collectRegistries(ctx).map(registryTask);
|
|
6618
6690
|
}
|
|
6619
6691
|
async function run(options) {
|
|
6620
6692
|
const ctx = {
|
|
@@ -6634,21 +6706,9 @@ async function run(options) {
|
|
|
6634
6706
|
await createListr(
|
|
6635
6707
|
options.publishOnly ? {
|
|
6636
6708
|
title: "Publishing",
|
|
6637
|
-
task: (ctx2, parentTask) => parentTask.newListr(
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
case "npm":
|
|
6641
|
-
return npmPublishTasks;
|
|
6642
|
-
case "jsr":
|
|
6643
|
-
return jsrPublishTasks;
|
|
6644
|
-
case "crates":
|
|
6645
|
-
return cratesPublishTasks;
|
|
6646
|
-
default:
|
|
6647
|
-
return npmPublishTasks;
|
|
6648
|
-
}
|
|
6649
|
-
}),
|
|
6650
|
-
{ concurrent: true }
|
|
6651
|
-
)
|
|
6709
|
+
task: (ctx2, parentTask) => parentTask.newListr(collectPublishTasks(ctx2), {
|
|
6710
|
+
concurrent: true
|
|
6711
|
+
})
|
|
6652
6712
|
} : [
|
|
6653
6713
|
{
|
|
6654
6714
|
skip: options.skipTests,
|
|
@@ -6717,7 +6777,10 @@ async function run(options) {
|
|
|
6717
6777
|
}
|
|
6718
6778
|
}, ctx2);
|
|
6719
6779
|
await git.reset();
|
|
6720
|
-
const replaced = await replaceVersion(
|
|
6780
|
+
const replaced = await replaceVersion(
|
|
6781
|
+
ctx2.version,
|
|
6782
|
+
ctx2.packages
|
|
6783
|
+
);
|
|
6721
6784
|
for (const replacedFile of replaced) {
|
|
6722
6785
|
await git.stage(replacedFile);
|
|
6723
6786
|
}
|
|
@@ -6732,21 +6795,9 @@ async function run(options) {
|
|
|
6732
6795
|
{
|
|
6733
6796
|
skip: (ctx2) => options.skipPublish || !!ctx2.preview,
|
|
6734
6797
|
title: "Publishing",
|
|
6735
|
-
task: (ctx2, parentTask) => parentTask.newListr(
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
case "npm":
|
|
6739
|
-
return npmPublishTasks;
|
|
6740
|
-
case "jsr":
|
|
6741
|
-
return jsrPublishTasks;
|
|
6742
|
-
case "crates":
|
|
6743
|
-
return cratesPublishTasks;
|
|
6744
|
-
default:
|
|
6745
|
-
return npmPublishTasks;
|
|
6746
|
-
}
|
|
6747
|
-
}),
|
|
6748
|
-
{ concurrent: true }
|
|
6749
|
-
)
|
|
6798
|
+
task: (ctx2, parentTask) => parentTask.newListr(collectPublishTasks(ctx2), {
|
|
6799
|
+
concurrent: true
|
|
6800
|
+
})
|
|
6750
6801
|
},
|
|
6751
6802
|
{
|
|
6752
6803
|
title: "Pushing tags to GitHub",
|
|
@@ -6848,11 +6899,11 @@ function generateChangelog(version2, entries, depUpdates) {
|
|
|
6848
6899
|
|
|
6849
6900
|
// src/changeset/migrate.ts
|
|
6850
6901
|
var import_node_fs2 = require("fs");
|
|
6851
|
-
var
|
|
6902
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
6852
6903
|
var import_node_process9 = __toESM(require("process"), 1);
|
|
6853
6904
|
var SKIPPED_FILES = /* @__PURE__ */ new Set(["config.json", "README.md"]);
|
|
6854
6905
|
function migrateFromChangesets(cwd = import_node_process9.default.cwd()) {
|
|
6855
|
-
const changesetDir =
|
|
6906
|
+
const changesetDir = import_node_path6.default.join(cwd, ".changeset");
|
|
6856
6907
|
if (!(0, import_node_fs2.existsSync)(changesetDir)) {
|
|
6857
6908
|
return {
|
|
6858
6909
|
success: false,
|
|
@@ -6861,7 +6912,7 @@ function migrateFromChangesets(cwd = import_node_process9.default.cwd()) {
|
|
|
6861
6912
|
configMigrated: false
|
|
6862
6913
|
};
|
|
6863
6914
|
}
|
|
6864
|
-
const pubmDir =
|
|
6915
|
+
const pubmDir = import_node_path6.default.join(cwd, ".pubm", "changesets");
|
|
6865
6916
|
(0, import_node_fs2.mkdirSync)(pubmDir, { recursive: true });
|
|
6866
6917
|
const files = (0, import_node_fs2.readdirSync)(changesetDir);
|
|
6867
6918
|
const migratedFiles = [];
|
|
@@ -6876,15 +6927,15 @@ function migrateFromChangesets(cwd = import_node_process9.default.cwd()) {
|
|
|
6876
6927
|
}
|
|
6877
6928
|
if (file === "pre.json") {
|
|
6878
6929
|
(0, import_node_fs2.copyFileSync)(
|
|
6879
|
-
|
|
6880
|
-
|
|
6930
|
+
import_node_path6.default.join(changesetDir, file),
|
|
6931
|
+
import_node_path6.default.resolve(cwd, ".pubm", "pre.json")
|
|
6881
6932
|
);
|
|
6882
6933
|
migratedFiles.push(file);
|
|
6883
6934
|
continue;
|
|
6884
6935
|
}
|
|
6885
6936
|
if (file.endsWith(".md")) {
|
|
6886
|
-
const src =
|
|
6887
|
-
const dest =
|
|
6937
|
+
const src = import_node_path6.default.join(changesetDir, file);
|
|
6938
|
+
const dest = import_node_path6.default.join(pubmDir, file);
|
|
6888
6939
|
(0, import_node_fs2.copyFileSync)(src, dest);
|
|
6889
6940
|
migratedFiles.push(file);
|
|
6890
6941
|
}
|
|
@@ -6931,10 +6982,10 @@ function parseChangeset(content, fileName) {
|
|
|
6931
6982
|
|
|
6932
6983
|
// src/changeset/reader.ts
|
|
6933
6984
|
var import_node_fs3 = require("fs");
|
|
6934
|
-
var
|
|
6985
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
6935
6986
|
var import_node_process10 = __toESM(require("process"), 1);
|
|
6936
6987
|
function readChangesets(cwd = import_node_process10.default.cwd()) {
|
|
6937
|
-
const changesetsDir =
|
|
6988
|
+
const changesetsDir = import_node_path7.default.join(cwd, ".pubm", "changesets");
|
|
6938
6989
|
if (!(0, import_node_fs3.existsSync)(changesetsDir)) {
|
|
6939
6990
|
return [];
|
|
6940
6991
|
}
|
|
@@ -6944,7 +6995,7 @@ function readChangesets(cwd = import_node_process10.default.cwd()) {
|
|
|
6944
6995
|
if (!file.endsWith(".md") || file === "README.md") {
|
|
6945
6996
|
continue;
|
|
6946
6997
|
}
|
|
6947
|
-
const filePath =
|
|
6998
|
+
const filePath = import_node_path7.default.join(changesetsDir, file);
|
|
6948
6999
|
const content = (0, import_node_fs3.readFileSync)(filePath, "utf-8");
|
|
6949
7000
|
changesets.push(parseChangeset(content, file));
|
|
6950
7001
|
}
|
|
@@ -7014,7 +7065,7 @@ function calculateVersionBumps(currentVersions, cwd = import_node_process12.defa
|
|
|
7014
7065
|
|
|
7015
7066
|
// src/changeset/writer.ts
|
|
7016
7067
|
var import_node_fs4 = require("fs");
|
|
7017
|
-
var
|
|
7068
|
+
var import_node_path8 = __toESM(require("path"), 1);
|
|
7018
7069
|
var import_node_process13 = __toESM(require("process"), 1);
|
|
7019
7070
|
var import_yaml2 = require("yaml");
|
|
7020
7071
|
var adjectives = [
|
|
@@ -7109,11 +7160,11 @@ ${summary}
|
|
|
7109
7160
|
return content;
|
|
7110
7161
|
}
|
|
7111
7162
|
function writeChangeset(releases, summary, cwd = import_node_process13.default.cwd()) {
|
|
7112
|
-
const changesetsDir =
|
|
7163
|
+
const changesetsDir = import_node_path8.default.join(cwd, ".pubm", "changesets");
|
|
7113
7164
|
(0, import_node_fs4.mkdirSync)(changesetsDir, { recursive: true });
|
|
7114
7165
|
const id = generateChangesetId();
|
|
7115
7166
|
const fileName = `${id}.md`;
|
|
7116
|
-
const filePath =
|
|
7167
|
+
const filePath = import_node_path8.default.join(changesetsDir, fileName);
|
|
7117
7168
|
const content = generateChangesetContent(releases, summary);
|
|
7118
7169
|
(0, import_node_fs4.writeFileSync)(filePath, content, "utf-8");
|
|
7119
7170
|
return filePath;
|
|
@@ -7172,23 +7223,23 @@ function topologicalSort(graph) {
|
|
|
7172
7223
|
|
|
7173
7224
|
// src/monorepo/discover.ts
|
|
7174
7225
|
var import_node_fs6 = require("fs");
|
|
7175
|
-
var
|
|
7226
|
+
var import_node_path10 = __toESM(require("path"), 1);
|
|
7176
7227
|
var import_micromatch = __toESM(require("micromatch"), 1);
|
|
7177
7228
|
|
|
7178
7229
|
// src/monorepo/workspace.ts
|
|
7179
7230
|
var import_node_fs5 = require("fs");
|
|
7180
|
-
var
|
|
7231
|
+
var import_node_path9 = require("path");
|
|
7181
7232
|
var import_yaml3 = require("yaml");
|
|
7182
7233
|
function detectWorkspace(cwd) {
|
|
7183
7234
|
const root = cwd ?? process.cwd();
|
|
7184
|
-
const pnpmWorkspacePath = (0,
|
|
7235
|
+
const pnpmWorkspacePath = (0, import_node_path9.join)(root, "pnpm-workspace.yaml");
|
|
7185
7236
|
if ((0, import_node_fs5.existsSync)(pnpmWorkspacePath)) {
|
|
7186
7237
|
const content = (0, import_node_fs5.readFileSync)(pnpmWorkspacePath, "utf-8");
|
|
7187
7238
|
const parsed = (0, import_yaml3.parse)(content);
|
|
7188
7239
|
const packages = parsed?.packages ?? [];
|
|
7189
7240
|
return { type: "pnpm", patterns: packages };
|
|
7190
7241
|
}
|
|
7191
|
-
const packageJsonPath = (0,
|
|
7242
|
+
const packageJsonPath = (0, import_node_path9.join)(root, "package.json");
|
|
7192
7243
|
if ((0, import_node_fs5.existsSync)(packageJsonPath)) {
|
|
7193
7244
|
const content = (0, import_node_fs5.readFileSync)(packageJsonPath, "utf-8");
|
|
7194
7245
|
const pkg = JSON.parse(content);
|
|
@@ -7249,9 +7300,9 @@ function applyLinkedGroup(bumps, group) {
|
|
|
7249
7300
|
|
|
7250
7301
|
// src/prerelease/pre.ts
|
|
7251
7302
|
var import_node_fs7 = require("fs");
|
|
7252
|
-
var
|
|
7303
|
+
var import_node_path11 = __toESM(require("path"), 1);
|
|
7253
7304
|
function getPreStatePath(cwd) {
|
|
7254
|
-
return
|
|
7305
|
+
return import_node_path11.default.resolve(cwd ?? process.cwd(), ".pubm", "pre.json");
|
|
7255
7306
|
}
|
|
7256
7307
|
function readPreState(cwd) {
|
|
7257
7308
|
const filePath = getPreStatePath(cwd);
|
|
@@ -7268,7 +7319,7 @@ function enterPreMode(tag, cwd) {
|
|
|
7268
7319
|
"Already in pre mode. Exit pre mode first before entering a new one."
|
|
7269
7320
|
);
|
|
7270
7321
|
}
|
|
7271
|
-
const dir =
|
|
7322
|
+
const dir = import_node_path11.default.dirname(filePath);
|
|
7272
7323
|
if (!(0, import_node_fs7.existsSync)(dir)) {
|
|
7273
7324
|
(0, import_node_fs7.mkdirSync)(dir, { recursive: true });
|
|
7274
7325
|
}
|
|
@@ -7310,10 +7361,10 @@ function generateSnapshotVersion(options) {
|
|
|
7310
7361
|
|
|
7311
7362
|
// src/validate/entry-points.ts
|
|
7312
7363
|
var import_node_fs8 = require("fs");
|
|
7313
|
-
var
|
|
7364
|
+
var import_node_path12 = __toESM(require("path"), 1);
|
|
7314
7365
|
var SIMPLE_FIELDS = ["main", "module", "types", "typings"];
|
|
7315
7366
|
function checkPath(filePath, cwd) {
|
|
7316
|
-
return (0, import_node_fs8.existsSync)(
|
|
7367
|
+
return (0, import_node_fs8.existsSync)(import_node_path12.default.resolve(cwd, filePath));
|
|
7317
7368
|
}
|
|
7318
7369
|
function validateExports(exports2, cwd, prefix = "exports") {
|
|
7319
7370
|
const errors = [];
|