pubm 0.1.4 → 0.1.5
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 +181 -35
- package/dist/index.cjs +203 -127
- package/dist/index.d.cts +49 -45
- package/dist/index.d.ts +49 -45
- package/dist/index.js +194 -118
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1960,6 +1960,80 @@ __export(src_exports, {
|
|
|
1960
1960
|
});
|
|
1961
1961
|
module.exports = __toCommonJS(src_exports);
|
|
1962
1962
|
|
|
1963
|
+
// src/config/defaults.ts
|
|
1964
|
+
var defaultValidate = {
|
|
1965
|
+
cleanInstall: true,
|
|
1966
|
+
entryPoints: true,
|
|
1967
|
+
extraneousFiles: true
|
|
1968
|
+
};
|
|
1969
|
+
var defaultSnapshot = {
|
|
1970
|
+
useCalculatedVersion: false,
|
|
1971
|
+
prereleaseTemplate: "{tag}-{timestamp}"
|
|
1972
|
+
};
|
|
1973
|
+
var defaultConfig = {
|
|
1974
|
+
versioning: "independent",
|
|
1975
|
+
branch: "main",
|
|
1976
|
+
changelog: true,
|
|
1977
|
+
changelogFormat: "default",
|
|
1978
|
+
commit: false,
|
|
1979
|
+
access: "public",
|
|
1980
|
+
fixed: [],
|
|
1981
|
+
linked: [],
|
|
1982
|
+
updateInternalDependencies: "patch",
|
|
1983
|
+
ignore: [],
|
|
1984
|
+
tag: "latest",
|
|
1985
|
+
contents: ".",
|
|
1986
|
+
saveToken: true,
|
|
1987
|
+
releaseDraft: true,
|
|
1988
|
+
releaseNotes: true,
|
|
1989
|
+
registries: ["npm", "jsr"],
|
|
1990
|
+
rollbackStrategy: "individual"
|
|
1991
|
+
};
|
|
1992
|
+
function resolveConfig(config) {
|
|
1993
|
+
const packages = config.packages ?? [
|
|
1994
|
+
{ path: ".", registries: ["npm", "jsr"] }
|
|
1995
|
+
];
|
|
1996
|
+
return {
|
|
1997
|
+
...defaultConfig,
|
|
1998
|
+
...config,
|
|
1999
|
+
packages,
|
|
2000
|
+
validate: { ...defaultValidate, ...config.validate },
|
|
2001
|
+
snapshot: { ...defaultSnapshot, ...config.snapshot }
|
|
2002
|
+
};
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
// src/config/loader.ts
|
|
2006
|
+
var import_promises = require("fs/promises");
|
|
2007
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
2008
|
+
var CONFIG_FILES = [
|
|
2009
|
+
"pubm.config.ts",
|
|
2010
|
+
"pubm.config.mts",
|
|
2011
|
+
"pubm.config.cts",
|
|
2012
|
+
"pubm.config.js",
|
|
2013
|
+
"pubm.config.mjs",
|
|
2014
|
+
"pubm.config.cjs"
|
|
2015
|
+
];
|
|
2016
|
+
async function findConfigFile(cwd) {
|
|
2017
|
+
for (const file of CONFIG_FILES) {
|
|
2018
|
+
const filePath = import_node_path.default.join(cwd, file);
|
|
2019
|
+
try {
|
|
2020
|
+
if ((await (0, import_promises.stat)(filePath)).isFile()) {
|
|
2021
|
+
return filePath;
|
|
2022
|
+
}
|
|
2023
|
+
} catch {
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
return null;
|
|
2027
|
+
}
|
|
2028
|
+
async function loadConfig(cwd = process.cwd()) {
|
|
2029
|
+
const configPath = await findConfigFile(cwd);
|
|
2030
|
+
if (!configPath) return null;
|
|
2031
|
+
const { createJiti } = await import("jiti");
|
|
2032
|
+
const jiti = createJiti(cwd, { interopDefault: true });
|
|
2033
|
+
const mod = await jiti.import(configPath);
|
|
2034
|
+
return mod.default ?? mod;
|
|
2035
|
+
}
|
|
2036
|
+
|
|
1963
2037
|
// src/options.ts
|
|
1964
2038
|
var defaultOptions = {
|
|
1965
2039
|
testScript: "test",
|
|
@@ -1969,13 +2043,16 @@ var defaultOptions = {
|
|
|
1969
2043
|
registries: ["npm", "jsr"]
|
|
1970
2044
|
};
|
|
1971
2045
|
function resolveOptions(options) {
|
|
1972
|
-
const
|
|
2046
|
+
const defined = Object.fromEntries(
|
|
2047
|
+
Object.entries(options).filter(([, v]) => v !== void 0)
|
|
2048
|
+
);
|
|
2049
|
+
const nextOptions = { ...defaultOptions, ...defined };
|
|
1973
2050
|
return nextOptions;
|
|
1974
2051
|
}
|
|
1975
2052
|
|
|
1976
2053
|
// src/tasks/runner.ts
|
|
1977
2054
|
var import_node_process8 = __toESM(require("process"), 1);
|
|
1978
|
-
var
|
|
2055
|
+
var import_promise_spawn3 = __toESM(require("@npmcli/promise-spawn"), 1);
|
|
1979
2056
|
|
|
1980
2057
|
// node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs
|
|
1981
2058
|
var import_index = __toESM(require_eventemitter3(), 1);
|
|
@@ -1996,15 +2073,15 @@ var isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !is
|
|
|
1996
2073
|
var isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
|
1997
2074
|
var isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
1998
2075
|
var replaceClose = (index, string, close, replace, head = string.substring(0, index) + replace, tail = string.substring(index + close.length), next = tail.indexOf(close)) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
|
|
1999
|
-
var clearBleed = (index, string,
|
|
2000
|
-
var filterEmpty = (
|
|
2076
|
+
var clearBleed = (index, string, open4, close, replace) => index < 0 ? open4 + string + close : open4 + replaceClose(index, string, close, replace) + close;
|
|
2077
|
+
var filterEmpty = (open4, close, replace = open4, at = open4.length + 1) => (string) => string || !(string === "" || string === void 0) ? clearBleed(
|
|
2001
2078
|
("" + string).indexOf(close, at),
|
|
2002
2079
|
string,
|
|
2003
|
-
|
|
2080
|
+
open4,
|
|
2004
2081
|
close,
|
|
2005
2082
|
replace
|
|
2006
2083
|
) : "";
|
|
2007
|
-
var init = (
|
|
2084
|
+
var init = (open4, close, replace) => filterEmpty(`\x1B[${open4}m`, `\x1B[${close}m`, replace);
|
|
2008
2085
|
var colors = {
|
|
2009
2086
|
reset: init(0, 0),
|
|
2010
2087
|
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
@@ -4530,7 +4607,8 @@ var Git = class {
|
|
|
4530
4607
|
async revisionDiffsCount() {
|
|
4531
4608
|
try {
|
|
4532
4609
|
return Number.parseInt(
|
|
4533
|
-
await this.git(["rev-list", "@{u}...HEAD", "--count", "--left-only"])
|
|
4610
|
+
await this.git(["rev-list", "@{u}...HEAD", "--count", "--left-only"]),
|
|
4611
|
+
10
|
|
4534
4612
|
);
|
|
4535
4613
|
} catch (error) {
|
|
4536
4614
|
throw new GitError(
|
|
@@ -4776,8 +4854,8 @@ function createListr(...args) {
|
|
|
4776
4854
|
}
|
|
4777
4855
|
|
|
4778
4856
|
// src/utils/package.ts
|
|
4779
|
-
var
|
|
4780
|
-
var
|
|
4857
|
+
var import_promises2 = require("fs/promises");
|
|
4858
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
4781
4859
|
var import_node_process5 = __toESM(require("process"), 1);
|
|
4782
4860
|
var cachedPackageJson = {};
|
|
4783
4861
|
var cachedJsrJson = {};
|
|
@@ -4787,16 +4865,16 @@ function patchCachedJsrJson(contents, { cwd = import_node_process5.default.cwd()
|
|
|
4787
4865
|
async function findOutFile(file, { cwd = import_node_process5.default.cwd() } = {}) {
|
|
4788
4866
|
let directory = cwd;
|
|
4789
4867
|
let filePath = "";
|
|
4790
|
-
const { root } =
|
|
4868
|
+
const { root } = import_node_path2.default.parse(cwd);
|
|
4791
4869
|
while (directory) {
|
|
4792
|
-
filePath =
|
|
4870
|
+
filePath = import_node_path2.default.join(directory, file);
|
|
4793
4871
|
try {
|
|
4794
|
-
if ((await (0,
|
|
4872
|
+
if ((await (0, import_promises2.stat)(filePath)).isFile()) {
|
|
4795
4873
|
break;
|
|
4796
4874
|
}
|
|
4797
4875
|
} catch {
|
|
4798
4876
|
}
|
|
4799
|
-
directory =
|
|
4877
|
+
directory = import_node_path2.default.dirname(directory);
|
|
4800
4878
|
if (directory === root) return null;
|
|
4801
4879
|
}
|
|
4802
4880
|
return filePath;
|
|
@@ -4808,7 +4886,7 @@ async function getPackageJson({
|
|
|
4808
4886
|
if (cachedPackageJson[cwd]) return cachedPackageJson[cwd];
|
|
4809
4887
|
try {
|
|
4810
4888
|
const packageJsonPath = await findOutFile("package.json");
|
|
4811
|
-
const raw = packageJsonPath && (await (0,
|
|
4889
|
+
const raw = packageJsonPath && (await (0, import_promises2.readFile)(packageJsonPath)).toString();
|
|
4812
4890
|
if (!raw) {
|
|
4813
4891
|
if (!fallbackJsr) {
|
|
4814
4892
|
throw new Error(
|
|
@@ -4841,7 +4919,7 @@ async function getJsrJson({
|
|
|
4841
4919
|
if (cachedJsrJson[cwd]) return cachedJsrJson[cwd];
|
|
4842
4920
|
try {
|
|
4843
4921
|
const jsrJsonPath = await findOutFile("jsr.json");
|
|
4844
|
-
const raw = jsrJsonPath && (await (0,
|
|
4922
|
+
const raw = jsrJsonPath && (await (0, import_promises2.readFile)(jsrJsonPath)).toString();
|
|
4845
4923
|
if (!raw) {
|
|
4846
4924
|
if (!fallbackPackage) {
|
|
4847
4925
|
throw new Error(
|
|
@@ -4930,9 +5008,9 @@ async function replaceVersion(version2) {
|
|
|
4930
5008
|
(async () => {
|
|
4931
5009
|
const packageJsonPath = await findOutFile("package.json");
|
|
4932
5010
|
if (!packageJsonPath) return void 0;
|
|
4933
|
-
const packageJson = (await (0,
|
|
5011
|
+
const packageJson = (await (0, import_promises2.readFile)(packageJsonPath)).toString();
|
|
4934
5012
|
try {
|
|
4935
|
-
await (0,
|
|
5013
|
+
await (0, import_promises2.writeFile)(
|
|
4936
5014
|
packageJsonPath,
|
|
4937
5015
|
packageJson.replace(versionRegex, `$1${version2}$2`)
|
|
4938
5016
|
);
|
|
@@ -4947,9 +5025,9 @@ async function replaceVersion(version2) {
|
|
|
4947
5025
|
(async () => {
|
|
4948
5026
|
const jsrJsonPath = await findOutFile("jsr.json");
|
|
4949
5027
|
if (!jsrJsonPath) return void 0;
|
|
4950
|
-
const jsrJson = (await (0,
|
|
5028
|
+
const jsrJson = (await (0, import_promises2.readFile)(jsrJsonPath)).toString();
|
|
4951
5029
|
try {
|
|
4952
|
-
await (0,
|
|
5030
|
+
await (0, import_promises2.writeFile)(
|
|
4953
5031
|
jsrJsonPath,
|
|
4954
5032
|
jsrJson.replace(versionRegex, `$1${version2}$2`)
|
|
4955
5033
|
);
|
|
@@ -4982,8 +5060,8 @@ async function getPackageManager() {
|
|
|
4982
5060
|
}
|
|
4983
5061
|
|
|
4984
5062
|
// src/ecosystem/rust.ts
|
|
4985
|
-
var
|
|
4986
|
-
var
|
|
5063
|
+
var import_promises3 = require("fs/promises");
|
|
5064
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
4987
5065
|
var import_smol_toml = require("smol-toml");
|
|
4988
5066
|
|
|
4989
5067
|
// src/ecosystem/ecosystem.ts
|
|
@@ -4997,14 +5075,14 @@ var Ecosystem = class {
|
|
|
4997
5075
|
var RustEcosystem = class extends Ecosystem {
|
|
4998
5076
|
static async detect(packagePath) {
|
|
4999
5077
|
try {
|
|
5000
|
-
return (await (0,
|
|
5078
|
+
return (await (0, import_promises3.stat)(import_node_path3.default.join(packagePath, "Cargo.toml"))).isFile();
|
|
5001
5079
|
} catch {
|
|
5002
5080
|
return false;
|
|
5003
5081
|
}
|
|
5004
5082
|
}
|
|
5005
5083
|
async readCargoToml() {
|
|
5006
|
-
const raw = await (0,
|
|
5007
|
-
|
|
5084
|
+
const raw = await (0, import_promises3.readFile)(
|
|
5085
|
+
import_node_path3.default.join(this.packagePath, "Cargo.toml"),
|
|
5008
5086
|
"utf-8"
|
|
5009
5087
|
);
|
|
5010
5088
|
return (0, import_smol_toml.parse)(raw);
|
|
@@ -5020,12 +5098,12 @@ var RustEcosystem = class extends Ecosystem {
|
|
|
5020
5098
|
return pkg.version;
|
|
5021
5099
|
}
|
|
5022
5100
|
async writeVersion(newVersion) {
|
|
5023
|
-
const filePath =
|
|
5024
|
-
const raw = await (0,
|
|
5101
|
+
const filePath = import_node_path3.default.join(this.packagePath, "Cargo.toml");
|
|
5102
|
+
const raw = await (0, import_promises3.readFile)(filePath, "utf-8");
|
|
5025
5103
|
const cargo = (0, import_smol_toml.parse)(raw);
|
|
5026
5104
|
const pkg = cargo.package;
|
|
5027
5105
|
pkg.version = newVersion;
|
|
5028
|
-
await (0,
|
|
5106
|
+
await (0, import_promises3.writeFile)(filePath, (0, import_smol_toml.stringify)(cargo));
|
|
5029
5107
|
}
|
|
5030
5108
|
manifestFiles() {
|
|
5031
5109
|
return ["Cargo.toml"];
|
|
@@ -5206,6 +5284,7 @@ var cratesPublishTasks = {
|
|
|
5206
5284
|
// src/tasks/jsr.ts
|
|
5207
5285
|
var import_node_process6 = __toESM(require("process"), 1);
|
|
5208
5286
|
var import_prompt_adapter_enquirer = require("@listr2/prompt-adapter-enquirer");
|
|
5287
|
+
var import_promise_spawn = __toESM(require("@npmcli/promise-spawn"), 1);
|
|
5209
5288
|
|
|
5210
5289
|
// src/registry/jsr.ts
|
|
5211
5290
|
var import_tinyexec3 = require("tinyexec");
|
|
@@ -5213,7 +5292,7 @@ var import_tinyexec3 = require("tinyexec");
|
|
|
5213
5292
|
// src/utils/db.ts
|
|
5214
5293
|
var import_node_crypto = require("crypto");
|
|
5215
5294
|
var import_node_fs = require("fs");
|
|
5216
|
-
var
|
|
5295
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
5217
5296
|
var import_meta = {};
|
|
5218
5297
|
var a = "aes-256-cbc";
|
|
5219
5298
|
var n = (0, import_node_fs.statSync)(import_meta.dirname);
|
|
@@ -5229,7 +5308,7 @@ function d(g, h) {
|
|
|
5229
5308
|
}
|
|
5230
5309
|
var Db = class {
|
|
5231
5310
|
constructor() {
|
|
5232
|
-
__publicField(this, "path",
|
|
5311
|
+
__publicField(this, "path", import_node_path4.default.resolve(import_meta.dirname, ".pubm"));
|
|
5233
5312
|
try {
|
|
5234
5313
|
if (!(0, import_node_fs.statSync)(this.path).isDirectory()) {
|
|
5235
5314
|
(0, import_node_fs.mkdirSync)(this.path);
|
|
@@ -5247,7 +5326,7 @@ var Db = class {
|
|
|
5247
5326
|
set(field, value) {
|
|
5248
5327
|
try {
|
|
5249
5328
|
(0, import_node_fs.writeFileSync)(
|
|
5250
|
-
|
|
5329
|
+
import_node_path4.default.resolve(
|
|
5251
5330
|
this.path,
|
|
5252
5331
|
Buffer.from(e(field, field)).toString("base64")
|
|
5253
5332
|
),
|
|
@@ -5261,7 +5340,7 @@ var Db = class {
|
|
|
5261
5340
|
}
|
|
5262
5341
|
}
|
|
5263
5342
|
get(field) {
|
|
5264
|
-
const filePath =
|
|
5343
|
+
const filePath = import_node_path4.default.resolve(
|
|
5265
5344
|
this.path,
|
|
5266
5345
|
Buffer.from(e(field, field)).toString("base64")
|
|
5267
5346
|
);
|
|
@@ -5344,6 +5423,7 @@ var JsrRegisry = class extends Registry {
|
|
|
5344
5423
|
super(packageName, registry);
|
|
5345
5424
|
__publicField(this, "registry", "https://jsr.io");
|
|
5346
5425
|
__publicField(this, "client");
|
|
5426
|
+
__publicField(this, "packageCreationUrls");
|
|
5347
5427
|
this.client = new JsrClient(getApiEndpoint(this.registry));
|
|
5348
5428
|
}
|
|
5349
5429
|
async jsr(args) {
|
|
@@ -5385,9 +5465,19 @@ var JsrRegisry = class extends Registry {
|
|
|
5385
5465
|
throwOnError: true
|
|
5386
5466
|
}
|
|
5387
5467
|
);
|
|
5468
|
+
this.packageCreationUrls = void 0;
|
|
5388
5469
|
return true;
|
|
5389
5470
|
} catch (error) {
|
|
5390
5471
|
const stderr = error instanceof import_tinyexec3.NonZeroExitError ? error.output?.stderr : void 0;
|
|
5472
|
+
if (stderr?.includes("don't exist")) {
|
|
5473
|
+
const urls = [...stderr.matchAll(/https:\/\/jsr\.io\/new\S+/g)].map(
|
|
5474
|
+
(m) => m[0]
|
|
5475
|
+
);
|
|
5476
|
+
if (urls.length > 0) {
|
|
5477
|
+
this.packageCreationUrls = urls;
|
|
5478
|
+
return false;
|
|
5479
|
+
}
|
|
5480
|
+
}
|
|
5391
5481
|
throw new JsrError(
|
|
5392
5482
|
`Failed to run \`jsr publish --allow-dirty --token ***\`${stderr ? `
|
|
5393
5483
|
${stderr}` : ""}`,
|
|
@@ -5828,6 +5918,7 @@ async function npmRegistry() {
|
|
|
5828
5918
|
}
|
|
5829
5919
|
|
|
5830
5920
|
// src/tasks/jsr.ts
|
|
5921
|
+
var { open } = import_promise_spawn.default;
|
|
5831
5922
|
var JsrAvailableError = class extends AbstractError {
|
|
5832
5923
|
constructor(message, { cause } = {}) {
|
|
5833
5924
|
super(message, { cause });
|
|
@@ -6008,7 +6099,39 @@ var jsrPublishTasks = {
|
|
|
6008
6099
|
}
|
|
6009
6100
|
JsrClient.token = jsrTokenEnv;
|
|
6010
6101
|
}
|
|
6011
|
-
await jsr.publish();
|
|
6102
|
+
let result = await jsr.publish();
|
|
6103
|
+
if (!result && jsr.packageCreationUrls) {
|
|
6104
|
+
if (ctx.promptEnabled) {
|
|
6105
|
+
task.title = "Running jsr publish (package creation needed)";
|
|
6106
|
+
const urls = jsr.packageCreationUrls;
|
|
6107
|
+
const maxAttempts = 3;
|
|
6108
|
+
task.output = `Package doesn't exist on jsr. Create it at:
|
|
6109
|
+
${urls.map((url) => ` ${color.cyan(url)}`).join("\n")}`;
|
|
6110
|
+
open(urls[0]);
|
|
6111
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
6112
|
+
await task.prompt(import_prompt_adapter_enquirer.ListrEnquirerPromptAdapter).run({
|
|
6113
|
+
type: "input",
|
|
6114
|
+
message: `Press ${color.bold("enter")} after creating the package on jsr.io${attempt > 1 ? ` (attempt ${attempt}/${maxAttempts})` : ""}`
|
|
6115
|
+
});
|
|
6116
|
+
result = await jsr.publish();
|
|
6117
|
+
if (result) break;
|
|
6118
|
+
if (attempt < maxAttempts) {
|
|
6119
|
+
task.output = "Package still doesn't exist. Please create it and try again.";
|
|
6120
|
+
}
|
|
6121
|
+
}
|
|
6122
|
+
if (!result) {
|
|
6123
|
+
throw new JsrAvailableError(
|
|
6124
|
+
"Package creation not completed after 3 attempts."
|
|
6125
|
+
);
|
|
6126
|
+
}
|
|
6127
|
+
task.title = "Running jsr publish (package created)";
|
|
6128
|
+
} else {
|
|
6129
|
+
throw new JsrAvailableError(
|
|
6130
|
+
`Package doesn't exist on jsr. Create it at:
|
|
6131
|
+
${jsr.packageCreationUrls.join("\n")}`
|
|
6132
|
+
);
|
|
6133
|
+
}
|
|
6134
|
+
}
|
|
6012
6135
|
}
|
|
6013
6136
|
};
|
|
6014
6137
|
|
|
@@ -6016,8 +6139,8 @@ var jsrPublishTasks = {
|
|
|
6016
6139
|
var import_node_child_process = require("child_process");
|
|
6017
6140
|
var import_node_process7 = __toESM(require("process"), 1);
|
|
6018
6141
|
var import_prompt_adapter_enquirer2 = require("@listr2/prompt-adapter-enquirer");
|
|
6019
|
-
var
|
|
6020
|
-
var { open } =
|
|
6142
|
+
var import_promise_spawn2 = __toESM(require("@npmcli/promise-spawn"), 1);
|
|
6143
|
+
var { open: open2 } = import_promise_spawn2.default;
|
|
6021
6144
|
var NpmAvailableError = class extends AbstractError {
|
|
6022
6145
|
constructor(message, { cause } = {}) {
|
|
6023
6146
|
super(message, { cause });
|
|
@@ -6047,7 +6170,7 @@ var npmAvailableCheckTasks = {
|
|
|
6047
6170
|
if (urlMatch && !opened) {
|
|
6048
6171
|
opened = true;
|
|
6049
6172
|
task.output = `Login at: ${color.cyan(urlMatch[0])}`;
|
|
6050
|
-
|
|
6173
|
+
open2(urlMatch[0]);
|
|
6051
6174
|
child.stdin?.write("\n");
|
|
6052
6175
|
}
|
|
6053
6176
|
};
|
|
@@ -6475,8 +6598,24 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
6475
6598
|
});
|
|
6476
6599
|
|
|
6477
6600
|
// src/tasks/runner.ts
|
|
6478
|
-
var { open:
|
|
6601
|
+
var { open: open3 } = import_promise_spawn3.default;
|
|
6479
6602
|
var { prerelease } = import_semver3.default;
|
|
6603
|
+
function collectRegistries(ctx) {
|
|
6604
|
+
if (ctx.packages?.length) {
|
|
6605
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6606
|
+
const result = [];
|
|
6607
|
+
for (const pkg of ctx.packages) {
|
|
6608
|
+
for (const reg of pkg.registries) {
|
|
6609
|
+
if (!seen.has(reg)) {
|
|
6610
|
+
seen.add(reg);
|
|
6611
|
+
result.push(reg);
|
|
6612
|
+
}
|
|
6613
|
+
}
|
|
6614
|
+
}
|
|
6615
|
+
return result;
|
|
6616
|
+
}
|
|
6617
|
+
return ctx.registries;
|
|
6618
|
+
}
|
|
6480
6619
|
async function run(options) {
|
|
6481
6620
|
const ctx = {
|
|
6482
6621
|
...options,
|
|
@@ -6496,7 +6635,7 @@ async function run(options) {
|
|
|
6496
6635
|
options.publishOnly ? {
|
|
6497
6636
|
title: "Publishing",
|
|
6498
6637
|
task: (ctx2, parentTask) => parentTask.newListr(
|
|
6499
|
-
ctx2.
|
|
6638
|
+
collectRegistries(ctx2).map((registry) => {
|
|
6500
6639
|
switch (registry) {
|
|
6501
6640
|
case "npm":
|
|
6502
6641
|
return npmPublishTasks;
|
|
@@ -6594,7 +6733,7 @@ async function run(options) {
|
|
|
6594
6733
|
skip: (ctx2) => options.skipPublish || !!ctx2.preview,
|
|
6595
6734
|
title: "Publishing",
|
|
6596
6735
|
task: (ctx2, parentTask) => parentTask.newListr(
|
|
6597
|
-
ctx2.
|
|
6736
|
+
collectRegistries(ctx2).map((registry) => {
|
|
6598
6737
|
switch (registry) {
|
|
6599
6738
|
case "npm":
|
|
6600
6739
|
return npmPublishTasks;
|
|
@@ -6647,7 +6786,7 @@ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
|
6647
6786
|
);
|
|
6648
6787
|
const linkUrl = link2("Link", releaseDraftUrl.toString());
|
|
6649
6788
|
task.title += ` ${linkUrl}`;
|
|
6650
|
-
await
|
|
6789
|
+
await open3(releaseDraftUrl.toString());
|
|
6651
6790
|
}
|
|
6652
6791
|
}
|
|
6653
6792
|
]
|
|
@@ -6709,11 +6848,11 @@ function generateChangelog(version2, entries, depUpdates) {
|
|
|
6709
6848
|
|
|
6710
6849
|
// src/changeset/migrate.ts
|
|
6711
6850
|
var import_node_fs2 = require("fs");
|
|
6712
|
-
var
|
|
6851
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
6713
6852
|
var import_node_process9 = __toESM(require("process"), 1);
|
|
6714
6853
|
var SKIPPED_FILES = /* @__PURE__ */ new Set(["config.json", "README.md"]);
|
|
6715
6854
|
function migrateFromChangesets(cwd = import_node_process9.default.cwd()) {
|
|
6716
|
-
const changesetDir =
|
|
6855
|
+
const changesetDir = import_node_path5.default.join(cwd, ".changeset");
|
|
6717
6856
|
if (!(0, import_node_fs2.existsSync)(changesetDir)) {
|
|
6718
6857
|
return {
|
|
6719
6858
|
success: false,
|
|
@@ -6722,7 +6861,7 @@ function migrateFromChangesets(cwd = import_node_process9.default.cwd()) {
|
|
|
6722
6861
|
configMigrated: false
|
|
6723
6862
|
};
|
|
6724
6863
|
}
|
|
6725
|
-
const pubmDir =
|
|
6864
|
+
const pubmDir = import_node_path5.default.join(cwd, ".pubm", "changesets");
|
|
6726
6865
|
(0, import_node_fs2.mkdirSync)(pubmDir, { recursive: true });
|
|
6727
6866
|
const files = (0, import_node_fs2.readdirSync)(changesetDir);
|
|
6728
6867
|
const migratedFiles = [];
|
|
@@ -6737,15 +6876,15 @@ function migrateFromChangesets(cwd = import_node_process9.default.cwd()) {
|
|
|
6737
6876
|
}
|
|
6738
6877
|
if (file === "pre.json") {
|
|
6739
6878
|
(0, import_node_fs2.copyFileSync)(
|
|
6740
|
-
|
|
6741
|
-
|
|
6879
|
+
import_node_path5.default.join(changesetDir, file),
|
|
6880
|
+
import_node_path5.default.resolve(cwd, ".pubm", "pre.json")
|
|
6742
6881
|
);
|
|
6743
6882
|
migratedFiles.push(file);
|
|
6744
6883
|
continue;
|
|
6745
6884
|
}
|
|
6746
6885
|
if (file.endsWith(".md")) {
|
|
6747
|
-
const src =
|
|
6748
|
-
const dest =
|
|
6886
|
+
const src = import_node_path5.default.join(changesetDir, file);
|
|
6887
|
+
const dest = import_node_path5.default.join(pubmDir, file);
|
|
6749
6888
|
(0, import_node_fs2.copyFileSync)(src, dest);
|
|
6750
6889
|
migratedFiles.push(file);
|
|
6751
6890
|
}
|
|
@@ -6792,10 +6931,10 @@ function parseChangeset(content, fileName) {
|
|
|
6792
6931
|
|
|
6793
6932
|
// src/changeset/reader.ts
|
|
6794
6933
|
var import_node_fs3 = require("fs");
|
|
6795
|
-
var
|
|
6934
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
6796
6935
|
var import_node_process10 = __toESM(require("process"), 1);
|
|
6797
6936
|
function readChangesets(cwd = import_node_process10.default.cwd()) {
|
|
6798
|
-
const changesetsDir =
|
|
6937
|
+
const changesetsDir = import_node_path6.default.join(cwd, ".pubm", "changesets");
|
|
6799
6938
|
if (!(0, import_node_fs3.existsSync)(changesetsDir)) {
|
|
6800
6939
|
return [];
|
|
6801
6940
|
}
|
|
@@ -6805,7 +6944,7 @@ function readChangesets(cwd = import_node_process10.default.cwd()) {
|
|
|
6805
6944
|
if (!file.endsWith(".md") || file === "README.md") {
|
|
6806
6945
|
continue;
|
|
6807
6946
|
}
|
|
6808
|
-
const filePath =
|
|
6947
|
+
const filePath = import_node_path6.default.join(changesetsDir, file);
|
|
6809
6948
|
const content = (0, import_node_fs3.readFileSync)(filePath, "utf-8");
|
|
6810
6949
|
changesets.push(parseChangeset(content, file));
|
|
6811
6950
|
}
|
|
@@ -6875,7 +7014,7 @@ function calculateVersionBumps(currentVersions, cwd = import_node_process12.defa
|
|
|
6875
7014
|
|
|
6876
7015
|
// src/changeset/writer.ts
|
|
6877
7016
|
var import_node_fs4 = require("fs");
|
|
6878
|
-
var
|
|
7017
|
+
var import_node_path7 = __toESM(require("path"), 1);
|
|
6879
7018
|
var import_node_process13 = __toESM(require("process"), 1);
|
|
6880
7019
|
var import_yaml2 = require("yaml");
|
|
6881
7020
|
var adjectives = [
|
|
@@ -6970,90 +7109,16 @@ ${summary}
|
|
|
6970
7109
|
return content;
|
|
6971
7110
|
}
|
|
6972
7111
|
function writeChangeset(releases, summary, cwd = import_node_process13.default.cwd()) {
|
|
6973
|
-
const changesetsDir =
|
|
7112
|
+
const changesetsDir = import_node_path7.default.join(cwd, ".pubm", "changesets");
|
|
6974
7113
|
(0, import_node_fs4.mkdirSync)(changesetsDir, { recursive: true });
|
|
6975
7114
|
const id = generateChangesetId();
|
|
6976
7115
|
const fileName = `${id}.md`;
|
|
6977
|
-
const filePath =
|
|
7116
|
+
const filePath = import_node_path7.default.join(changesetsDir, fileName);
|
|
6978
7117
|
const content = generateChangesetContent(releases, summary);
|
|
6979
7118
|
(0, import_node_fs4.writeFileSync)(filePath, content, "utf-8");
|
|
6980
7119
|
return filePath;
|
|
6981
7120
|
}
|
|
6982
7121
|
|
|
6983
|
-
// src/config/defaults.ts
|
|
6984
|
-
var defaultValidate = {
|
|
6985
|
-
cleanInstall: true,
|
|
6986
|
-
entryPoints: true,
|
|
6987
|
-
extraneousFiles: true
|
|
6988
|
-
};
|
|
6989
|
-
var defaultSnapshot = {
|
|
6990
|
-
useCalculatedVersion: false,
|
|
6991
|
-
prereleaseTemplate: "{tag}-{timestamp}"
|
|
6992
|
-
};
|
|
6993
|
-
var defaultConfig = {
|
|
6994
|
-
versioning: "independent",
|
|
6995
|
-
branch: "main",
|
|
6996
|
-
changelog: true,
|
|
6997
|
-
changelogFormat: "default",
|
|
6998
|
-
commit: false,
|
|
6999
|
-
access: "public",
|
|
7000
|
-
fixed: [],
|
|
7001
|
-
linked: [],
|
|
7002
|
-
updateInternalDependencies: "patch",
|
|
7003
|
-
ignore: [],
|
|
7004
|
-
tag: "latest",
|
|
7005
|
-
contents: ".",
|
|
7006
|
-
saveToken: true,
|
|
7007
|
-
releaseDraft: true,
|
|
7008
|
-
releaseNotes: true,
|
|
7009
|
-
registries: ["npm", "jsr"],
|
|
7010
|
-
rollbackStrategy: "individual"
|
|
7011
|
-
};
|
|
7012
|
-
function resolveConfig(config) {
|
|
7013
|
-
const packages = config.packages ?? [
|
|
7014
|
-
{ path: ".", registries: ["npm", "jsr"] }
|
|
7015
|
-
];
|
|
7016
|
-
return {
|
|
7017
|
-
...defaultConfig,
|
|
7018
|
-
...config,
|
|
7019
|
-
packages,
|
|
7020
|
-
validate: { ...defaultValidate, ...config.validate },
|
|
7021
|
-
snapshot: { ...defaultSnapshot, ...config.snapshot }
|
|
7022
|
-
};
|
|
7023
|
-
}
|
|
7024
|
-
|
|
7025
|
-
// src/config/loader.ts
|
|
7026
|
-
var import_promises3 = require("fs/promises");
|
|
7027
|
-
var import_node_path7 = __toESM(require("path"), 1);
|
|
7028
|
-
var CONFIG_FILES = [
|
|
7029
|
-
"pubm.config.ts",
|
|
7030
|
-
"pubm.config.mts",
|
|
7031
|
-
"pubm.config.cts",
|
|
7032
|
-
"pubm.config.js",
|
|
7033
|
-
"pubm.config.mjs",
|
|
7034
|
-
"pubm.config.cjs"
|
|
7035
|
-
];
|
|
7036
|
-
async function findConfigFile(cwd) {
|
|
7037
|
-
for (const file of CONFIG_FILES) {
|
|
7038
|
-
const filePath = import_node_path7.default.join(cwd, file);
|
|
7039
|
-
try {
|
|
7040
|
-
if ((await (0, import_promises3.stat)(filePath)).isFile()) {
|
|
7041
|
-
return filePath;
|
|
7042
|
-
}
|
|
7043
|
-
} catch {
|
|
7044
|
-
}
|
|
7045
|
-
}
|
|
7046
|
-
return null;
|
|
7047
|
-
}
|
|
7048
|
-
async function loadConfig(cwd = process.cwd()) {
|
|
7049
|
-
const configPath = await findConfigFile(cwd);
|
|
7050
|
-
if (!configPath) return null;
|
|
7051
|
-
const { createJiti } = await import("jiti");
|
|
7052
|
-
const jiti = createJiti(cwd, { interopDefault: true });
|
|
7053
|
-
const mod = await jiti.import(configPath);
|
|
7054
|
-
return mod.default ?? mod;
|
|
7055
|
-
}
|
|
7056
|
-
|
|
7057
7122
|
// src/config/types.ts
|
|
7058
7123
|
function defineConfig(config) {
|
|
7059
7124
|
return config;
|
|
@@ -7352,7 +7417,18 @@ function detectExtraneousFiles(files) {
|
|
|
7352
7417
|
|
|
7353
7418
|
// src/index.ts
|
|
7354
7419
|
async function pubm(options) {
|
|
7355
|
-
const
|
|
7420
|
+
const config = await loadConfig();
|
|
7421
|
+
const configOptions = {};
|
|
7422
|
+
if (config) {
|
|
7423
|
+
const resolved = resolveConfig(config);
|
|
7424
|
+
if (resolved.packages) {
|
|
7425
|
+
configOptions.packages = resolved.packages;
|
|
7426
|
+
}
|
|
7427
|
+
if (!options.registries && resolved.registries) {
|
|
7428
|
+
configOptions.registries = resolved.registries;
|
|
7429
|
+
}
|
|
7430
|
+
}
|
|
7431
|
+
const resolvedOptions = resolveOptions({ ...configOptions, ...options });
|
|
7356
7432
|
await run(resolvedOptions);
|
|
7357
7433
|
}
|
|
7358
7434
|
// Annotate the CommonJS export names for ESM import in node:
|