pubm 0.1.5 → 0.1.7
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 +237 -174
- package/dist/index.cjs +257 -194
- package/dist/index.js +254 -191
- 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,8 +6544,8 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
6501
6544
|
task: async (_2, parentTask2) => parentTask2.newListr(
|
|
6502
6545
|
[
|
|
6503
6546
|
{
|
|
6504
|
-
enabled: (ctx) => ctx.
|
|
6505
|
-
title: "Verifying if npm
|
|
6547
|
+
enabled: (ctx) => collectRegistries(ctx).includes("npm"),
|
|
6548
|
+
title: "Verifying if npm is installed",
|
|
6506
6549
|
task: async () => {
|
|
6507
6550
|
const npm = await npmRegistry();
|
|
6508
6551
|
if (!await npm.isInstalled()) {
|
|
@@ -6513,7 +6556,9 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
6513
6556
|
}
|
|
6514
6557
|
},
|
|
6515
6558
|
{
|
|
6516
|
-
enabled: (ctx) => ctx.
|
|
6559
|
+
enabled: (ctx) => collectRegistries(ctx).some(
|
|
6560
|
+
(registry) => registry === "jsr"
|
|
6561
|
+
),
|
|
6517
6562
|
title: "Verifying if jsr are installed",
|
|
6518
6563
|
task: async (_3, task) => {
|
|
6519
6564
|
const jsr = await jsrRegistry();
|
|
@@ -6544,7 +6589,7 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
6544
6589
|
},
|
|
6545
6590
|
{
|
|
6546
6591
|
title: "Checking if test and build scripts exist",
|
|
6547
|
-
skip: (ctx) => !needsPackageScripts(ctx
|
|
6592
|
+
skip: (ctx) => !needsPackageScripts(collectRegistries(ctx)),
|
|
6548
6593
|
task: async (ctx) => {
|
|
6549
6594
|
const { scripts } = await getPackageJson();
|
|
6550
6595
|
const errors = [];
|
|
@@ -6572,23 +6617,42 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
6572
6617
|
},
|
|
6573
6618
|
{
|
|
6574
6619
|
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
|
-
|
|
6620
|
+
task: (ctx, parentTask2) => {
|
|
6621
|
+
if (ctx.packages?.length) {
|
|
6622
|
+
const tasks = ctx.packages.flatMap(
|
|
6623
|
+
(pkg) => pkg.registries.map((registryKey) => {
|
|
6624
|
+
switch (registryKey) {
|
|
6625
|
+
case "npm":
|
|
6626
|
+
return npmAvailableCheckTasks;
|
|
6627
|
+
case "jsr":
|
|
6628
|
+
return jsrAvailableCheckTasks;
|
|
6629
|
+
case "crates":
|
|
6630
|
+
return createCratesAvailableCheckTask(pkg.path);
|
|
6631
|
+
default:
|
|
6632
|
+
return npmAvailableCheckTasks;
|
|
6633
|
+
}
|
|
6634
|
+
})
|
|
6635
|
+
);
|
|
6636
|
+
return parentTask2.newListr(tasks, { concurrent: true });
|
|
6590
6637
|
}
|
|
6591
|
-
|
|
6638
|
+
return parentTask2.newListr(
|
|
6639
|
+
collectRegistries(ctx).map((registryKey) => {
|
|
6640
|
+
switch (registryKey) {
|
|
6641
|
+
case "npm":
|
|
6642
|
+
return npmAvailableCheckTasks;
|
|
6643
|
+
case "jsr":
|
|
6644
|
+
return jsrAvailableCheckTasks;
|
|
6645
|
+
case "crates":
|
|
6646
|
+
return cratesAvailableCheckTasks;
|
|
6647
|
+
default:
|
|
6648
|
+
return npmAvailableCheckTasks;
|
|
6649
|
+
}
|
|
6650
|
+
}),
|
|
6651
|
+
{
|
|
6652
|
+
concurrent: true
|
|
6653
|
+
}
|
|
6654
|
+
);
|
|
6655
|
+
}
|
|
6592
6656
|
}
|
|
6593
6657
|
],
|
|
6594
6658
|
{
|
|
@@ -6600,21 +6664,27 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
6600
6664
|
// src/tasks/runner.ts
|
|
6601
6665
|
var { open: open3 } = import_promise_spawn3.default;
|
|
6602
6666
|
var { prerelease } = import_semver3.default;
|
|
6603
|
-
function
|
|
6667
|
+
function registryTask(registry) {
|
|
6668
|
+
switch (registry) {
|
|
6669
|
+
case "npm":
|
|
6670
|
+
return npmPublishTasks;
|
|
6671
|
+
case "jsr":
|
|
6672
|
+
return jsrPublishTasks;
|
|
6673
|
+
case "crates":
|
|
6674
|
+
return cratesPublishTasks;
|
|
6675
|
+
default:
|
|
6676
|
+
return npmPublishTasks;
|
|
6677
|
+
}
|
|
6678
|
+
}
|
|
6679
|
+
function collectPublishTasks(ctx) {
|
|
6604
6680
|
if (ctx.packages?.length) {
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
seen.add(reg);
|
|
6611
|
-
result.push(reg);
|
|
6612
|
-
}
|
|
6613
|
-
}
|
|
6614
|
-
}
|
|
6615
|
-
return result;
|
|
6681
|
+
return ctx.packages.flatMap(
|
|
6682
|
+
(pkg) => pkg.registries.map(
|
|
6683
|
+
(reg) => reg === "crates" ? createCratesPublishTask(pkg.path) : registryTask(reg)
|
|
6684
|
+
)
|
|
6685
|
+
);
|
|
6616
6686
|
}
|
|
6617
|
-
return ctx.
|
|
6687
|
+
return collectRegistries(ctx).map(registryTask);
|
|
6618
6688
|
}
|
|
6619
6689
|
async function run(options) {
|
|
6620
6690
|
const ctx = {
|
|
@@ -6634,21 +6704,9 @@ async function run(options) {
|
|
|
6634
6704
|
await createListr(
|
|
6635
6705
|
options.publishOnly ? {
|
|
6636
6706
|
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
|
-
)
|
|
6707
|
+
task: (ctx2, parentTask) => parentTask.newListr(collectPublishTasks(ctx2), {
|
|
6708
|
+
concurrent: true
|
|
6709
|
+
})
|
|
6652
6710
|
} : [
|
|
6653
6711
|
{
|
|
6654
6712
|
skip: options.skipTests,
|
|
@@ -6717,7 +6775,10 @@ async function run(options) {
|
|
|
6717
6775
|
}
|
|
6718
6776
|
}, ctx2);
|
|
6719
6777
|
await git.reset();
|
|
6720
|
-
const replaced = await replaceVersion(
|
|
6778
|
+
const replaced = await replaceVersion(
|
|
6779
|
+
ctx2.version,
|
|
6780
|
+
ctx2.packages
|
|
6781
|
+
);
|
|
6721
6782
|
for (const replacedFile of replaced) {
|
|
6722
6783
|
await git.stage(replacedFile);
|
|
6723
6784
|
}
|
|
@@ -6732,21 +6793,9 @@ async function run(options) {
|
|
|
6732
6793
|
{
|
|
6733
6794
|
skip: (ctx2) => options.skipPublish || !!ctx2.preview,
|
|
6734
6795
|
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
|
-
)
|
|
6796
|
+
task: (ctx2, parentTask) => parentTask.newListr(collectPublishTasks(ctx2), {
|
|
6797
|
+
concurrent: true
|
|
6798
|
+
})
|
|
6750
6799
|
},
|
|
6751
6800
|
{
|
|
6752
6801
|
title: "Pushing tags to GitHub",
|
|
@@ -6791,12 +6840,26 @@ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
|
6791
6840
|
}
|
|
6792
6841
|
]
|
|
6793
6842
|
).run(ctx);
|
|
6794
|
-
const
|
|
6795
|
-
const
|
|
6843
|
+
const registries = collectRegistries(ctx);
|
|
6844
|
+
const parts = [];
|
|
6845
|
+
if (registries.includes("npm")) {
|
|
6846
|
+
const npmPackageName = (await getPackageJson()).name;
|
|
6847
|
+
parts.push(`${color.bold(npmPackageName)} on ${color.green("npm")}`);
|
|
6848
|
+
}
|
|
6849
|
+
if (registries.includes("jsr")) {
|
|
6850
|
+
const jsrPackageName = (await getJsrJson()).name;
|
|
6851
|
+
parts.push(`${color.bold(jsrPackageName)} on ${color.yellow("jsr")}`);
|
|
6852
|
+
}
|
|
6853
|
+
if (registries.includes("crates")) {
|
|
6854
|
+
const crateNames = ctx.packages?.filter((pkg) => pkg.registries.includes("crates")).map((pkg) => pkg.path) ?? ["crate"];
|
|
6855
|
+
for (const name of crateNames) {
|
|
6856
|
+
parts.push(`${color.bold(name)} on ${color.red("crates.io")}`);
|
|
6857
|
+
}
|
|
6858
|
+
}
|
|
6796
6859
|
console.log(
|
|
6797
6860
|
`
|
|
6798
6861
|
|
|
6799
|
-
\u{1F680} Successfully published ${
|
|
6862
|
+
\u{1F680} Successfully published ${parts.join(", ")} ${color.blueBright(`v${ctx.version}`)} \u{1F680}
|
|
6800
6863
|
`
|
|
6801
6864
|
);
|
|
6802
6865
|
} catch (e2) {
|
|
@@ -6848,11 +6911,11 @@ function generateChangelog(version2, entries, depUpdates) {
|
|
|
6848
6911
|
|
|
6849
6912
|
// src/changeset/migrate.ts
|
|
6850
6913
|
var import_node_fs2 = require("fs");
|
|
6851
|
-
var
|
|
6914
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
6852
6915
|
var import_node_process9 = __toESM(require("process"), 1);
|
|
6853
6916
|
var SKIPPED_FILES = /* @__PURE__ */ new Set(["config.json", "README.md"]);
|
|
6854
6917
|
function migrateFromChangesets(cwd = import_node_process9.default.cwd()) {
|
|
6855
|
-
const changesetDir =
|
|
6918
|
+
const changesetDir = import_node_path6.default.join(cwd, ".changeset");
|
|
6856
6919
|
if (!(0, import_node_fs2.existsSync)(changesetDir)) {
|
|
6857
6920
|
return {
|
|
6858
6921
|
success: false,
|
|
@@ -6861,7 +6924,7 @@ function migrateFromChangesets(cwd = import_node_process9.default.cwd()) {
|
|
|
6861
6924
|
configMigrated: false
|
|
6862
6925
|
};
|
|
6863
6926
|
}
|
|
6864
|
-
const pubmDir =
|
|
6927
|
+
const pubmDir = import_node_path6.default.join(cwd, ".pubm", "changesets");
|
|
6865
6928
|
(0, import_node_fs2.mkdirSync)(pubmDir, { recursive: true });
|
|
6866
6929
|
const files = (0, import_node_fs2.readdirSync)(changesetDir);
|
|
6867
6930
|
const migratedFiles = [];
|
|
@@ -6876,15 +6939,15 @@ function migrateFromChangesets(cwd = import_node_process9.default.cwd()) {
|
|
|
6876
6939
|
}
|
|
6877
6940
|
if (file === "pre.json") {
|
|
6878
6941
|
(0, import_node_fs2.copyFileSync)(
|
|
6879
|
-
|
|
6880
|
-
|
|
6942
|
+
import_node_path6.default.join(changesetDir, file),
|
|
6943
|
+
import_node_path6.default.resolve(cwd, ".pubm", "pre.json")
|
|
6881
6944
|
);
|
|
6882
6945
|
migratedFiles.push(file);
|
|
6883
6946
|
continue;
|
|
6884
6947
|
}
|
|
6885
6948
|
if (file.endsWith(".md")) {
|
|
6886
|
-
const src =
|
|
6887
|
-
const dest =
|
|
6949
|
+
const src = import_node_path6.default.join(changesetDir, file);
|
|
6950
|
+
const dest = import_node_path6.default.join(pubmDir, file);
|
|
6888
6951
|
(0, import_node_fs2.copyFileSync)(src, dest);
|
|
6889
6952
|
migratedFiles.push(file);
|
|
6890
6953
|
}
|
|
@@ -6931,10 +6994,10 @@ function parseChangeset(content, fileName) {
|
|
|
6931
6994
|
|
|
6932
6995
|
// src/changeset/reader.ts
|
|
6933
6996
|
var import_node_fs3 = require("fs");
|
|
6934
|
-
var
|
|
6997
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
6935
6998
|
var import_node_process10 = __toESM(require("process"), 1);
|
|
6936
6999
|
function readChangesets(cwd = import_node_process10.default.cwd()) {
|
|
6937
|
-
const changesetsDir =
|
|
7000
|
+
const changesetsDir = import_node_path7.default.join(cwd, ".pubm", "changesets");
|
|
6938
7001
|
if (!(0, import_node_fs3.existsSync)(changesetsDir)) {
|
|
6939
7002
|
return [];
|
|
6940
7003
|
}
|
|
@@ -6944,7 +7007,7 @@ function readChangesets(cwd = import_node_process10.default.cwd()) {
|
|
|
6944
7007
|
if (!file.endsWith(".md") || file === "README.md") {
|
|
6945
7008
|
continue;
|
|
6946
7009
|
}
|
|
6947
|
-
const filePath =
|
|
7010
|
+
const filePath = import_node_path7.default.join(changesetsDir, file);
|
|
6948
7011
|
const content = (0, import_node_fs3.readFileSync)(filePath, "utf-8");
|
|
6949
7012
|
changesets.push(parseChangeset(content, file));
|
|
6950
7013
|
}
|
|
@@ -7014,7 +7077,7 @@ function calculateVersionBumps(currentVersions, cwd = import_node_process12.defa
|
|
|
7014
7077
|
|
|
7015
7078
|
// src/changeset/writer.ts
|
|
7016
7079
|
var import_node_fs4 = require("fs");
|
|
7017
|
-
var
|
|
7080
|
+
var import_node_path8 = __toESM(require("path"), 1);
|
|
7018
7081
|
var import_node_process13 = __toESM(require("process"), 1);
|
|
7019
7082
|
var import_yaml2 = require("yaml");
|
|
7020
7083
|
var adjectives = [
|
|
@@ -7109,11 +7172,11 @@ ${summary}
|
|
|
7109
7172
|
return content;
|
|
7110
7173
|
}
|
|
7111
7174
|
function writeChangeset(releases, summary, cwd = import_node_process13.default.cwd()) {
|
|
7112
|
-
const changesetsDir =
|
|
7175
|
+
const changesetsDir = import_node_path8.default.join(cwd, ".pubm", "changesets");
|
|
7113
7176
|
(0, import_node_fs4.mkdirSync)(changesetsDir, { recursive: true });
|
|
7114
7177
|
const id = generateChangesetId();
|
|
7115
7178
|
const fileName = `${id}.md`;
|
|
7116
|
-
const filePath =
|
|
7179
|
+
const filePath = import_node_path8.default.join(changesetsDir, fileName);
|
|
7117
7180
|
const content = generateChangesetContent(releases, summary);
|
|
7118
7181
|
(0, import_node_fs4.writeFileSync)(filePath, content, "utf-8");
|
|
7119
7182
|
return filePath;
|
|
@@ -7172,23 +7235,23 @@ function topologicalSort(graph) {
|
|
|
7172
7235
|
|
|
7173
7236
|
// src/monorepo/discover.ts
|
|
7174
7237
|
var import_node_fs6 = require("fs");
|
|
7175
|
-
var
|
|
7238
|
+
var import_node_path10 = __toESM(require("path"), 1);
|
|
7176
7239
|
var import_micromatch = __toESM(require("micromatch"), 1);
|
|
7177
7240
|
|
|
7178
7241
|
// src/monorepo/workspace.ts
|
|
7179
7242
|
var import_node_fs5 = require("fs");
|
|
7180
|
-
var
|
|
7243
|
+
var import_node_path9 = require("path");
|
|
7181
7244
|
var import_yaml3 = require("yaml");
|
|
7182
7245
|
function detectWorkspace(cwd) {
|
|
7183
7246
|
const root = cwd ?? process.cwd();
|
|
7184
|
-
const pnpmWorkspacePath = (0,
|
|
7247
|
+
const pnpmWorkspacePath = (0, import_node_path9.join)(root, "pnpm-workspace.yaml");
|
|
7185
7248
|
if ((0, import_node_fs5.existsSync)(pnpmWorkspacePath)) {
|
|
7186
7249
|
const content = (0, import_node_fs5.readFileSync)(pnpmWorkspacePath, "utf-8");
|
|
7187
7250
|
const parsed = (0, import_yaml3.parse)(content);
|
|
7188
7251
|
const packages = parsed?.packages ?? [];
|
|
7189
7252
|
return { type: "pnpm", patterns: packages };
|
|
7190
7253
|
}
|
|
7191
|
-
const packageJsonPath = (0,
|
|
7254
|
+
const packageJsonPath = (0, import_node_path9.join)(root, "package.json");
|
|
7192
7255
|
if ((0, import_node_fs5.existsSync)(packageJsonPath)) {
|
|
7193
7256
|
const content = (0, import_node_fs5.readFileSync)(packageJsonPath, "utf-8");
|
|
7194
7257
|
const pkg = JSON.parse(content);
|
|
@@ -7249,9 +7312,9 @@ function applyLinkedGroup(bumps, group) {
|
|
|
7249
7312
|
|
|
7250
7313
|
// src/prerelease/pre.ts
|
|
7251
7314
|
var import_node_fs7 = require("fs");
|
|
7252
|
-
var
|
|
7315
|
+
var import_node_path11 = __toESM(require("path"), 1);
|
|
7253
7316
|
function getPreStatePath(cwd) {
|
|
7254
|
-
return
|
|
7317
|
+
return import_node_path11.default.resolve(cwd ?? process.cwd(), ".pubm", "pre.json");
|
|
7255
7318
|
}
|
|
7256
7319
|
function readPreState(cwd) {
|
|
7257
7320
|
const filePath = getPreStatePath(cwd);
|
|
@@ -7268,7 +7331,7 @@ function enterPreMode(tag, cwd) {
|
|
|
7268
7331
|
"Already in pre mode. Exit pre mode first before entering a new one."
|
|
7269
7332
|
);
|
|
7270
7333
|
}
|
|
7271
|
-
const dir =
|
|
7334
|
+
const dir = import_node_path11.default.dirname(filePath);
|
|
7272
7335
|
if (!(0, import_node_fs7.existsSync)(dir)) {
|
|
7273
7336
|
(0, import_node_fs7.mkdirSync)(dir, { recursive: true });
|
|
7274
7337
|
}
|
|
@@ -7310,10 +7373,10 @@ function generateSnapshotVersion(options) {
|
|
|
7310
7373
|
|
|
7311
7374
|
// src/validate/entry-points.ts
|
|
7312
7375
|
var import_node_fs8 = require("fs");
|
|
7313
|
-
var
|
|
7376
|
+
var import_node_path12 = __toESM(require("path"), 1);
|
|
7314
7377
|
var SIMPLE_FIELDS = ["main", "module", "types", "typings"];
|
|
7315
7378
|
function checkPath(filePath, cwd) {
|
|
7316
|
-
return (0, import_node_fs8.existsSync)(
|
|
7379
|
+
return (0, import_node_fs8.existsSync)(import_node_path12.default.resolve(cwd, filePath));
|
|
7317
7380
|
}
|
|
7318
7381
|
function validateExports(exports2, cwd, prefix = "exports") {
|
|
7319
7382
|
const errors = [];
|