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.js
CHANGED
|
@@ -1927,6 +1927,80 @@ var init_cli_truncate = __esm({
|
|
|
1927
1927
|
}
|
|
1928
1928
|
});
|
|
1929
1929
|
|
|
1930
|
+
// src/config/defaults.ts
|
|
1931
|
+
var defaultValidate = {
|
|
1932
|
+
cleanInstall: true,
|
|
1933
|
+
entryPoints: true,
|
|
1934
|
+
extraneousFiles: true
|
|
1935
|
+
};
|
|
1936
|
+
var defaultSnapshot = {
|
|
1937
|
+
useCalculatedVersion: false,
|
|
1938
|
+
prereleaseTemplate: "{tag}-{timestamp}"
|
|
1939
|
+
};
|
|
1940
|
+
var defaultConfig = {
|
|
1941
|
+
versioning: "independent",
|
|
1942
|
+
branch: "main",
|
|
1943
|
+
changelog: true,
|
|
1944
|
+
changelogFormat: "default",
|
|
1945
|
+
commit: false,
|
|
1946
|
+
access: "public",
|
|
1947
|
+
fixed: [],
|
|
1948
|
+
linked: [],
|
|
1949
|
+
updateInternalDependencies: "patch",
|
|
1950
|
+
ignore: [],
|
|
1951
|
+
tag: "latest",
|
|
1952
|
+
contents: ".",
|
|
1953
|
+
saveToken: true,
|
|
1954
|
+
releaseDraft: true,
|
|
1955
|
+
releaseNotes: true,
|
|
1956
|
+
registries: ["npm", "jsr"],
|
|
1957
|
+
rollbackStrategy: "individual"
|
|
1958
|
+
};
|
|
1959
|
+
function resolveConfig(config) {
|
|
1960
|
+
const packages = config.packages ?? [
|
|
1961
|
+
{ path: ".", registries: ["npm", "jsr"] }
|
|
1962
|
+
];
|
|
1963
|
+
return {
|
|
1964
|
+
...defaultConfig,
|
|
1965
|
+
...config,
|
|
1966
|
+
packages,
|
|
1967
|
+
validate: { ...defaultValidate, ...config.validate },
|
|
1968
|
+
snapshot: { ...defaultSnapshot, ...config.snapshot }
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
// src/config/loader.ts
|
|
1973
|
+
import { stat } from "node:fs/promises";
|
|
1974
|
+
import path from "node:path";
|
|
1975
|
+
var CONFIG_FILES = [
|
|
1976
|
+
"pubm.config.ts",
|
|
1977
|
+
"pubm.config.mts",
|
|
1978
|
+
"pubm.config.cts",
|
|
1979
|
+
"pubm.config.js",
|
|
1980
|
+
"pubm.config.mjs",
|
|
1981
|
+
"pubm.config.cjs"
|
|
1982
|
+
];
|
|
1983
|
+
async function findConfigFile(cwd) {
|
|
1984
|
+
for (const file of CONFIG_FILES) {
|
|
1985
|
+
const filePath = path.join(cwd, file);
|
|
1986
|
+
try {
|
|
1987
|
+
if ((await stat(filePath)).isFile()) {
|
|
1988
|
+
return filePath;
|
|
1989
|
+
}
|
|
1990
|
+
} catch {
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
return null;
|
|
1994
|
+
}
|
|
1995
|
+
async function loadConfig(cwd = process.cwd()) {
|
|
1996
|
+
const configPath = await findConfigFile(cwd);
|
|
1997
|
+
if (!configPath) return null;
|
|
1998
|
+
const { createJiti } = await import("jiti");
|
|
1999
|
+
const jiti = createJiti(cwd, { interopDefault: true });
|
|
2000
|
+
const mod = await jiti.import(configPath);
|
|
2001
|
+
return mod.default ?? mod;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
1930
2004
|
// src/options.ts
|
|
1931
2005
|
var defaultOptions = {
|
|
1932
2006
|
testScript: "test",
|
|
@@ -1936,13 +2010,16 @@ var defaultOptions = {
|
|
|
1936
2010
|
registries: ["npm", "jsr"]
|
|
1937
2011
|
};
|
|
1938
2012
|
function resolveOptions(options) {
|
|
1939
|
-
const
|
|
2013
|
+
const defined = Object.fromEntries(
|
|
2014
|
+
Object.entries(options).filter(([, v]) => v !== void 0)
|
|
2015
|
+
);
|
|
2016
|
+
const nextOptions = { ...defaultOptions, ...defined };
|
|
1940
2017
|
return nextOptions;
|
|
1941
2018
|
}
|
|
1942
2019
|
|
|
1943
2020
|
// src/tasks/runner.ts
|
|
1944
2021
|
import process10 from "node:process";
|
|
1945
|
-
import
|
|
2022
|
+
import npmCli3 from "@npmcli/promise-spawn";
|
|
1946
2023
|
|
|
1947
2024
|
// node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs
|
|
1948
2025
|
var import_index = __toESM(require_eventemitter3(), 1);
|
|
@@ -1963,15 +2040,15 @@ var isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !is
|
|
|
1963
2040
|
var isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
|
|
1964
2041
|
var isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
|
|
1965
2042
|
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));
|
|
1966
|
-
var clearBleed = (index, string,
|
|
1967
|
-
var filterEmpty = (
|
|
2043
|
+
var clearBleed = (index, string, open4, close, replace) => index < 0 ? open4 + string + close : open4 + replaceClose(index, string, close, replace) + close;
|
|
2044
|
+
var filterEmpty = (open4, close, replace = open4, at = open4.length + 1) => (string) => string || !(string === "" || string === void 0) ? clearBleed(
|
|
1968
2045
|
("" + string).indexOf(close, at),
|
|
1969
2046
|
string,
|
|
1970
|
-
|
|
2047
|
+
open4,
|
|
1971
2048
|
close,
|
|
1972
2049
|
replace
|
|
1973
2050
|
) : "";
|
|
1974
|
-
var init = (
|
|
2051
|
+
var init = (open4, close, replace) => filterEmpty(`\x1B[${open4}m`, `\x1B[${close}m`, replace);
|
|
1975
2052
|
var colors = {
|
|
1976
2053
|
reset: init(0, 0),
|
|
1977
2054
|
bold: init(1, 22, "\x1B[22m\x1B[1m"),
|
|
@@ -4497,7 +4574,8 @@ var Git = class {
|
|
|
4497
4574
|
async revisionDiffsCount() {
|
|
4498
4575
|
try {
|
|
4499
4576
|
return Number.parseInt(
|
|
4500
|
-
await this.git(["rev-list", "@{u}...HEAD", "--count", "--left-only"])
|
|
4577
|
+
await this.git(["rev-list", "@{u}...HEAD", "--count", "--left-only"]),
|
|
4578
|
+
10
|
|
4501
4579
|
);
|
|
4502
4580
|
} catch (error) {
|
|
4503
4581
|
throw new GitError(
|
|
@@ -4743,8 +4821,8 @@ function createListr(...args) {
|
|
|
4743
4821
|
}
|
|
4744
4822
|
|
|
4745
4823
|
// src/utils/package.ts
|
|
4746
|
-
import { readFile, stat, writeFile } from "node:fs/promises";
|
|
4747
|
-
import
|
|
4824
|
+
import { readFile, stat as stat2, writeFile } from "node:fs/promises";
|
|
4825
|
+
import path2 from "node:path";
|
|
4748
4826
|
import process7 from "node:process";
|
|
4749
4827
|
var cachedPackageJson = {};
|
|
4750
4828
|
var cachedJsrJson = {};
|
|
@@ -4754,16 +4832,16 @@ function patchCachedJsrJson(contents, { cwd = process7.cwd() } = {}) {
|
|
|
4754
4832
|
async function findOutFile(file, { cwd = process7.cwd() } = {}) {
|
|
4755
4833
|
let directory = cwd;
|
|
4756
4834
|
let filePath = "";
|
|
4757
|
-
const { root } =
|
|
4835
|
+
const { root } = path2.parse(cwd);
|
|
4758
4836
|
while (directory) {
|
|
4759
|
-
filePath =
|
|
4837
|
+
filePath = path2.join(directory, file);
|
|
4760
4838
|
try {
|
|
4761
|
-
if ((await
|
|
4839
|
+
if ((await stat2(filePath)).isFile()) {
|
|
4762
4840
|
break;
|
|
4763
4841
|
}
|
|
4764
4842
|
} catch {
|
|
4765
4843
|
}
|
|
4766
|
-
directory =
|
|
4844
|
+
directory = path2.dirname(directory);
|
|
4767
4845
|
if (directory === root) return null;
|
|
4768
4846
|
}
|
|
4769
4847
|
return filePath;
|
|
@@ -4949,8 +5027,8 @@ async function getPackageManager() {
|
|
|
4949
5027
|
}
|
|
4950
5028
|
|
|
4951
5029
|
// src/ecosystem/rust.ts
|
|
4952
|
-
import { readFile as readFile2, stat as
|
|
4953
|
-
import
|
|
5030
|
+
import { readFile as readFile2, stat as stat3, writeFile as writeFile2 } from "node:fs/promises";
|
|
5031
|
+
import path3 from "node:path";
|
|
4954
5032
|
import { parse, stringify } from "smol-toml";
|
|
4955
5033
|
|
|
4956
5034
|
// src/ecosystem/ecosystem.ts
|
|
@@ -4964,14 +5042,14 @@ var Ecosystem = class {
|
|
|
4964
5042
|
var RustEcosystem = class extends Ecosystem {
|
|
4965
5043
|
static async detect(packagePath) {
|
|
4966
5044
|
try {
|
|
4967
|
-
return (await
|
|
5045
|
+
return (await stat3(path3.join(packagePath, "Cargo.toml"))).isFile();
|
|
4968
5046
|
} catch {
|
|
4969
5047
|
return false;
|
|
4970
5048
|
}
|
|
4971
5049
|
}
|
|
4972
5050
|
async readCargoToml() {
|
|
4973
5051
|
const raw = await readFile2(
|
|
4974
|
-
|
|
5052
|
+
path3.join(this.packagePath, "Cargo.toml"),
|
|
4975
5053
|
"utf-8"
|
|
4976
5054
|
);
|
|
4977
5055
|
return parse(raw);
|
|
@@ -4987,7 +5065,7 @@ var RustEcosystem = class extends Ecosystem {
|
|
|
4987
5065
|
return pkg.version;
|
|
4988
5066
|
}
|
|
4989
5067
|
async writeVersion(newVersion) {
|
|
4990
|
-
const filePath =
|
|
5068
|
+
const filePath = path3.join(this.packagePath, "Cargo.toml");
|
|
4991
5069
|
const raw = await readFile2(filePath, "utf-8");
|
|
4992
5070
|
const cargo = parse(raw);
|
|
4993
5071
|
const pkg = cargo.package;
|
|
@@ -5173,6 +5251,7 @@ var cratesPublishTasks = {
|
|
|
5173
5251
|
// src/tasks/jsr.ts
|
|
5174
5252
|
import process8 from "node:process";
|
|
5175
5253
|
import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
|
|
5254
|
+
import npmCli from "@npmcli/promise-spawn";
|
|
5176
5255
|
|
|
5177
5256
|
// src/registry/jsr.ts
|
|
5178
5257
|
import { exec as exec4, NonZeroExitError } from "tinyexec";
|
|
@@ -5180,7 +5259,7 @@ import { exec as exec4, NonZeroExitError } from "tinyexec";
|
|
|
5180
5259
|
// src/utils/db.ts
|
|
5181
5260
|
import { createCipheriv, createDecipheriv, createHash } from "node:crypto";
|
|
5182
5261
|
import { mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
5183
|
-
import
|
|
5262
|
+
import path4 from "node:path";
|
|
5184
5263
|
var a = "aes-256-cbc";
|
|
5185
5264
|
var n = statSync(import.meta.dirname);
|
|
5186
5265
|
var k = `${n.rdev}${n.birthtimeMs}${n.nlink}${n.gid}`;
|
|
@@ -5195,7 +5274,7 @@ function d(g, h) {
|
|
|
5195
5274
|
}
|
|
5196
5275
|
var Db = class {
|
|
5197
5276
|
constructor() {
|
|
5198
|
-
__publicField(this, "path",
|
|
5277
|
+
__publicField(this, "path", path4.resolve(import.meta.dirname, ".pubm"));
|
|
5199
5278
|
try {
|
|
5200
5279
|
if (!statSync(this.path).isDirectory()) {
|
|
5201
5280
|
mkdirSync(this.path);
|
|
@@ -5213,7 +5292,7 @@ var Db = class {
|
|
|
5213
5292
|
set(field, value) {
|
|
5214
5293
|
try {
|
|
5215
5294
|
writeFileSync(
|
|
5216
|
-
|
|
5295
|
+
path4.resolve(
|
|
5217
5296
|
this.path,
|
|
5218
5297
|
Buffer.from(e(field, field)).toString("base64")
|
|
5219
5298
|
),
|
|
@@ -5227,7 +5306,7 @@ var Db = class {
|
|
|
5227
5306
|
}
|
|
5228
5307
|
}
|
|
5229
5308
|
get(field) {
|
|
5230
|
-
const filePath =
|
|
5309
|
+
const filePath = path4.resolve(
|
|
5231
5310
|
this.path,
|
|
5232
5311
|
Buffer.from(e(field, field)).toString("base64")
|
|
5233
5312
|
);
|
|
@@ -5309,6 +5388,7 @@ var JsrRegisry = class extends Registry {
|
|
|
5309
5388
|
super(packageName, registry);
|
|
5310
5389
|
__publicField(this, "registry", "https://jsr.io");
|
|
5311
5390
|
__publicField(this, "client");
|
|
5391
|
+
__publicField(this, "packageCreationUrls");
|
|
5312
5392
|
this.client = new JsrClient(getApiEndpoint(this.registry));
|
|
5313
5393
|
}
|
|
5314
5394
|
async jsr(args) {
|
|
@@ -5350,9 +5430,19 @@ var JsrRegisry = class extends Registry {
|
|
|
5350
5430
|
throwOnError: true
|
|
5351
5431
|
}
|
|
5352
5432
|
);
|
|
5433
|
+
this.packageCreationUrls = void 0;
|
|
5353
5434
|
return true;
|
|
5354
5435
|
} catch (error) {
|
|
5355
5436
|
const stderr = error instanceof NonZeroExitError ? error.output?.stderr : void 0;
|
|
5437
|
+
if (stderr?.includes("don't exist")) {
|
|
5438
|
+
const urls = [...stderr.matchAll(/https:\/\/jsr\.io\/new\S+/g)].map(
|
|
5439
|
+
(m) => m[0]
|
|
5440
|
+
);
|
|
5441
|
+
if (urls.length > 0) {
|
|
5442
|
+
this.packageCreationUrls = urls;
|
|
5443
|
+
return false;
|
|
5444
|
+
}
|
|
5445
|
+
}
|
|
5356
5446
|
throw new JsrError(
|
|
5357
5447
|
`Failed to run \`jsr publish --allow-dirty --token ***\`${stderr ? `
|
|
5358
5448
|
${stderr}` : ""}`,
|
|
@@ -5793,6 +5883,7 @@ async function npmRegistry() {
|
|
|
5793
5883
|
}
|
|
5794
5884
|
|
|
5795
5885
|
// src/tasks/jsr.ts
|
|
5886
|
+
var { open } = npmCli;
|
|
5796
5887
|
var JsrAvailableError = class extends AbstractError {
|
|
5797
5888
|
constructor(message, { cause } = {}) {
|
|
5798
5889
|
super(message, { cause });
|
|
@@ -5973,7 +6064,39 @@ var jsrPublishTasks = {
|
|
|
5973
6064
|
}
|
|
5974
6065
|
JsrClient.token = jsrTokenEnv;
|
|
5975
6066
|
}
|
|
5976
|
-
await jsr.publish();
|
|
6067
|
+
let result = await jsr.publish();
|
|
6068
|
+
if (!result && jsr.packageCreationUrls) {
|
|
6069
|
+
if (ctx.promptEnabled) {
|
|
6070
|
+
task.title = "Running jsr publish (package creation needed)";
|
|
6071
|
+
const urls = jsr.packageCreationUrls;
|
|
6072
|
+
const maxAttempts = 3;
|
|
6073
|
+
task.output = `Package doesn't exist on jsr. Create it at:
|
|
6074
|
+
${urls.map((url) => ` ${color.cyan(url)}`).join("\n")}`;
|
|
6075
|
+
open(urls[0]);
|
|
6076
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
6077
|
+
await task.prompt(ListrEnquirerPromptAdapter).run({
|
|
6078
|
+
type: "input",
|
|
6079
|
+
message: `Press ${color.bold("enter")} after creating the package on jsr.io${attempt > 1 ? ` (attempt ${attempt}/${maxAttempts})` : ""}`
|
|
6080
|
+
});
|
|
6081
|
+
result = await jsr.publish();
|
|
6082
|
+
if (result) break;
|
|
6083
|
+
if (attempt < maxAttempts) {
|
|
6084
|
+
task.output = "Package still doesn't exist. Please create it and try again.";
|
|
6085
|
+
}
|
|
6086
|
+
}
|
|
6087
|
+
if (!result) {
|
|
6088
|
+
throw new JsrAvailableError(
|
|
6089
|
+
"Package creation not completed after 3 attempts."
|
|
6090
|
+
);
|
|
6091
|
+
}
|
|
6092
|
+
task.title = "Running jsr publish (package created)";
|
|
6093
|
+
} else {
|
|
6094
|
+
throw new JsrAvailableError(
|
|
6095
|
+
`Package doesn't exist on jsr. Create it at:
|
|
6096
|
+
${jsr.packageCreationUrls.join("\n")}`
|
|
6097
|
+
);
|
|
6098
|
+
}
|
|
6099
|
+
}
|
|
5977
6100
|
}
|
|
5978
6101
|
};
|
|
5979
6102
|
|
|
@@ -5981,8 +6104,8 @@ var jsrPublishTasks = {
|
|
|
5981
6104
|
import { spawn } from "node:child_process";
|
|
5982
6105
|
import process9 from "node:process";
|
|
5983
6106
|
import { ListrEnquirerPromptAdapter as ListrEnquirerPromptAdapter2 } from "@listr2/prompt-adapter-enquirer";
|
|
5984
|
-
import
|
|
5985
|
-
var { open } =
|
|
6107
|
+
import npmCli2 from "@npmcli/promise-spawn";
|
|
6108
|
+
var { open: open2 } = npmCli2;
|
|
5986
6109
|
var NpmAvailableError = class extends AbstractError {
|
|
5987
6110
|
constructor(message, { cause } = {}) {
|
|
5988
6111
|
super(message, { cause });
|
|
@@ -6012,7 +6135,7 @@ var npmAvailableCheckTasks = {
|
|
|
6012
6135
|
if (urlMatch && !opened) {
|
|
6013
6136
|
opened = true;
|
|
6014
6137
|
task.output = `Login at: ${color.cyan(urlMatch[0])}`;
|
|
6015
|
-
|
|
6138
|
+
open2(urlMatch[0]);
|
|
6016
6139
|
child.stdin?.write("\n");
|
|
6017
6140
|
}
|
|
6018
6141
|
};
|
|
@@ -6439,8 +6562,24 @@ var requiredConditionsCheckTask = (options) => createListr({
|
|
|
6439
6562
|
});
|
|
6440
6563
|
|
|
6441
6564
|
// src/tasks/runner.ts
|
|
6442
|
-
var { open:
|
|
6565
|
+
var { open: open3 } = npmCli3;
|
|
6443
6566
|
var { prerelease } = SemVer;
|
|
6567
|
+
function collectRegistries(ctx) {
|
|
6568
|
+
if (ctx.packages?.length) {
|
|
6569
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6570
|
+
const result = [];
|
|
6571
|
+
for (const pkg of ctx.packages) {
|
|
6572
|
+
for (const reg of pkg.registries) {
|
|
6573
|
+
if (!seen.has(reg)) {
|
|
6574
|
+
seen.add(reg);
|
|
6575
|
+
result.push(reg);
|
|
6576
|
+
}
|
|
6577
|
+
}
|
|
6578
|
+
}
|
|
6579
|
+
return result;
|
|
6580
|
+
}
|
|
6581
|
+
return ctx.registries;
|
|
6582
|
+
}
|
|
6444
6583
|
async function run(options) {
|
|
6445
6584
|
const ctx = {
|
|
6446
6585
|
...options,
|
|
@@ -6460,7 +6599,7 @@ async function run(options) {
|
|
|
6460
6599
|
options.publishOnly ? {
|
|
6461
6600
|
title: "Publishing",
|
|
6462
6601
|
task: (ctx2, parentTask) => parentTask.newListr(
|
|
6463
|
-
ctx2.
|
|
6602
|
+
collectRegistries(ctx2).map((registry) => {
|
|
6464
6603
|
switch (registry) {
|
|
6465
6604
|
case "npm":
|
|
6466
6605
|
return npmPublishTasks;
|
|
@@ -6558,7 +6697,7 @@ async function run(options) {
|
|
|
6558
6697
|
skip: (ctx2) => options.skipPublish || !!ctx2.preview,
|
|
6559
6698
|
title: "Publishing",
|
|
6560
6699
|
task: (ctx2, parentTask) => parentTask.newListr(
|
|
6561
|
-
ctx2.
|
|
6700
|
+
collectRegistries(ctx2).map((registry) => {
|
|
6562
6701
|
switch (registry) {
|
|
6563
6702
|
case "npm":
|
|
6564
6703
|
return npmPublishTasks;
|
|
@@ -6611,7 +6750,7 @@ ${repositoryUrl}/compare/${lastRev}...${latestTag}`;
|
|
|
6611
6750
|
);
|
|
6612
6751
|
const linkUrl = link2("Link", releaseDraftUrl.toString());
|
|
6613
6752
|
task.title += ` ${linkUrl}`;
|
|
6614
|
-
await
|
|
6753
|
+
await open3(releaseDraftUrl.toString());
|
|
6615
6754
|
}
|
|
6616
6755
|
}
|
|
6617
6756
|
]
|
|
@@ -6673,11 +6812,11 @@ function generateChangelog(version2, entries, depUpdates) {
|
|
|
6673
6812
|
|
|
6674
6813
|
// src/changeset/migrate.ts
|
|
6675
6814
|
import { copyFileSync, existsSync, mkdirSync as mkdirSync2, readdirSync } from "node:fs";
|
|
6676
|
-
import
|
|
6815
|
+
import path5 from "node:path";
|
|
6677
6816
|
import process11 from "node:process";
|
|
6678
6817
|
var SKIPPED_FILES = /* @__PURE__ */ new Set(["config.json", "README.md"]);
|
|
6679
6818
|
function migrateFromChangesets(cwd = process11.cwd()) {
|
|
6680
|
-
const changesetDir =
|
|
6819
|
+
const changesetDir = path5.join(cwd, ".changeset");
|
|
6681
6820
|
if (!existsSync(changesetDir)) {
|
|
6682
6821
|
return {
|
|
6683
6822
|
success: false,
|
|
@@ -6686,7 +6825,7 @@ function migrateFromChangesets(cwd = process11.cwd()) {
|
|
|
6686
6825
|
configMigrated: false
|
|
6687
6826
|
};
|
|
6688
6827
|
}
|
|
6689
|
-
const pubmDir =
|
|
6828
|
+
const pubmDir = path5.join(cwd, ".pubm", "changesets");
|
|
6690
6829
|
mkdirSync2(pubmDir, { recursive: true });
|
|
6691
6830
|
const files = readdirSync(changesetDir);
|
|
6692
6831
|
const migratedFiles = [];
|
|
@@ -6701,15 +6840,15 @@ function migrateFromChangesets(cwd = process11.cwd()) {
|
|
|
6701
6840
|
}
|
|
6702
6841
|
if (file === "pre.json") {
|
|
6703
6842
|
copyFileSync(
|
|
6704
|
-
|
|
6705
|
-
|
|
6843
|
+
path5.join(changesetDir, file),
|
|
6844
|
+
path5.resolve(cwd, ".pubm", "pre.json")
|
|
6706
6845
|
);
|
|
6707
6846
|
migratedFiles.push(file);
|
|
6708
6847
|
continue;
|
|
6709
6848
|
}
|
|
6710
6849
|
if (file.endsWith(".md")) {
|
|
6711
|
-
const src =
|
|
6712
|
-
const dest =
|
|
6850
|
+
const src = path5.join(changesetDir, file);
|
|
6851
|
+
const dest = path5.join(pubmDir, file);
|
|
6713
6852
|
copyFileSync(src, dest);
|
|
6714
6853
|
migratedFiles.push(file);
|
|
6715
6854
|
}
|
|
@@ -6756,10 +6895,10 @@ function parseChangeset(content, fileName) {
|
|
|
6756
6895
|
|
|
6757
6896
|
// src/changeset/reader.ts
|
|
6758
6897
|
import { existsSync as existsSync2, readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
6759
|
-
import
|
|
6898
|
+
import path6 from "node:path";
|
|
6760
6899
|
import process12 from "node:process";
|
|
6761
6900
|
function readChangesets(cwd = process12.cwd()) {
|
|
6762
|
-
const changesetsDir =
|
|
6901
|
+
const changesetsDir = path6.join(cwd, ".pubm", "changesets");
|
|
6763
6902
|
if (!existsSync2(changesetsDir)) {
|
|
6764
6903
|
return [];
|
|
6765
6904
|
}
|
|
@@ -6769,7 +6908,7 @@ function readChangesets(cwd = process12.cwd()) {
|
|
|
6769
6908
|
if (!file.endsWith(".md") || file === "README.md") {
|
|
6770
6909
|
continue;
|
|
6771
6910
|
}
|
|
6772
|
-
const filePath =
|
|
6911
|
+
const filePath = path6.join(changesetsDir, file);
|
|
6773
6912
|
const content = readFileSync2(filePath, "utf-8");
|
|
6774
6913
|
changesets.push(parseChangeset(content, file));
|
|
6775
6914
|
}
|
|
@@ -6839,7 +6978,7 @@ function calculateVersionBumps(currentVersions, cwd = process14.cwd()) {
|
|
|
6839
6978
|
|
|
6840
6979
|
// src/changeset/writer.ts
|
|
6841
6980
|
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
6842
|
-
import
|
|
6981
|
+
import path7 from "node:path";
|
|
6843
6982
|
import process15 from "node:process";
|
|
6844
6983
|
import { stringify as stringifyYaml } from "yaml";
|
|
6845
6984
|
var adjectives = [
|
|
@@ -6934,90 +7073,16 @@ ${summary}
|
|
|
6934
7073
|
return content;
|
|
6935
7074
|
}
|
|
6936
7075
|
function writeChangeset(releases, summary, cwd = process15.cwd()) {
|
|
6937
|
-
const changesetsDir =
|
|
7076
|
+
const changesetsDir = path7.join(cwd, ".pubm", "changesets");
|
|
6938
7077
|
mkdirSync3(changesetsDir, { recursive: true });
|
|
6939
7078
|
const id = generateChangesetId();
|
|
6940
7079
|
const fileName = `${id}.md`;
|
|
6941
|
-
const filePath =
|
|
7080
|
+
const filePath = path7.join(changesetsDir, fileName);
|
|
6942
7081
|
const content = generateChangesetContent(releases, summary);
|
|
6943
7082
|
writeFileSync2(filePath, content, "utf-8");
|
|
6944
7083
|
return filePath;
|
|
6945
7084
|
}
|
|
6946
7085
|
|
|
6947
|
-
// src/config/defaults.ts
|
|
6948
|
-
var defaultValidate = {
|
|
6949
|
-
cleanInstall: true,
|
|
6950
|
-
entryPoints: true,
|
|
6951
|
-
extraneousFiles: true
|
|
6952
|
-
};
|
|
6953
|
-
var defaultSnapshot = {
|
|
6954
|
-
useCalculatedVersion: false,
|
|
6955
|
-
prereleaseTemplate: "{tag}-{timestamp}"
|
|
6956
|
-
};
|
|
6957
|
-
var defaultConfig = {
|
|
6958
|
-
versioning: "independent",
|
|
6959
|
-
branch: "main",
|
|
6960
|
-
changelog: true,
|
|
6961
|
-
changelogFormat: "default",
|
|
6962
|
-
commit: false,
|
|
6963
|
-
access: "public",
|
|
6964
|
-
fixed: [],
|
|
6965
|
-
linked: [],
|
|
6966
|
-
updateInternalDependencies: "patch",
|
|
6967
|
-
ignore: [],
|
|
6968
|
-
tag: "latest",
|
|
6969
|
-
contents: ".",
|
|
6970
|
-
saveToken: true,
|
|
6971
|
-
releaseDraft: true,
|
|
6972
|
-
releaseNotes: true,
|
|
6973
|
-
registries: ["npm", "jsr"],
|
|
6974
|
-
rollbackStrategy: "individual"
|
|
6975
|
-
};
|
|
6976
|
-
function resolveConfig(config) {
|
|
6977
|
-
const packages = config.packages ?? [
|
|
6978
|
-
{ path: ".", registries: ["npm", "jsr"] }
|
|
6979
|
-
];
|
|
6980
|
-
return {
|
|
6981
|
-
...defaultConfig,
|
|
6982
|
-
...config,
|
|
6983
|
-
packages,
|
|
6984
|
-
validate: { ...defaultValidate, ...config.validate },
|
|
6985
|
-
snapshot: { ...defaultSnapshot, ...config.snapshot }
|
|
6986
|
-
};
|
|
6987
|
-
}
|
|
6988
|
-
|
|
6989
|
-
// src/config/loader.ts
|
|
6990
|
-
import { stat as stat3 } from "node:fs/promises";
|
|
6991
|
-
import path7 from "node:path";
|
|
6992
|
-
var CONFIG_FILES = [
|
|
6993
|
-
"pubm.config.ts",
|
|
6994
|
-
"pubm.config.mts",
|
|
6995
|
-
"pubm.config.cts",
|
|
6996
|
-
"pubm.config.js",
|
|
6997
|
-
"pubm.config.mjs",
|
|
6998
|
-
"pubm.config.cjs"
|
|
6999
|
-
];
|
|
7000
|
-
async function findConfigFile(cwd) {
|
|
7001
|
-
for (const file of CONFIG_FILES) {
|
|
7002
|
-
const filePath = path7.join(cwd, file);
|
|
7003
|
-
try {
|
|
7004
|
-
if ((await stat3(filePath)).isFile()) {
|
|
7005
|
-
return filePath;
|
|
7006
|
-
}
|
|
7007
|
-
} catch {
|
|
7008
|
-
}
|
|
7009
|
-
}
|
|
7010
|
-
return null;
|
|
7011
|
-
}
|
|
7012
|
-
async function loadConfig(cwd = process.cwd()) {
|
|
7013
|
-
const configPath = await findConfigFile(cwd);
|
|
7014
|
-
if (!configPath) return null;
|
|
7015
|
-
const { createJiti } = await import("jiti");
|
|
7016
|
-
const jiti = createJiti(cwd, { interopDefault: true });
|
|
7017
|
-
const mod = await jiti.import(configPath);
|
|
7018
|
-
return mod.default ?? mod;
|
|
7019
|
-
}
|
|
7020
|
-
|
|
7021
7086
|
// src/config/types.ts
|
|
7022
7087
|
function defineConfig(config) {
|
|
7023
7088
|
return config;
|
|
@@ -7322,7 +7387,18 @@ function detectExtraneousFiles(files) {
|
|
|
7322
7387
|
|
|
7323
7388
|
// src/index.ts
|
|
7324
7389
|
async function pubm(options) {
|
|
7325
|
-
const
|
|
7390
|
+
const config = await loadConfig();
|
|
7391
|
+
const configOptions = {};
|
|
7392
|
+
if (config) {
|
|
7393
|
+
const resolved = resolveConfig(config);
|
|
7394
|
+
if (resolved.packages) {
|
|
7395
|
+
configOptions.packages = resolved.packages;
|
|
7396
|
+
}
|
|
7397
|
+
if (!options.registries && resolved.registries) {
|
|
7398
|
+
configOptions.registries = resolved.registries;
|
|
7399
|
+
}
|
|
7400
|
+
}
|
|
7401
|
+
const resolvedOptions = resolveOptions({ ...configOptions, ...options });
|
|
7326
7402
|
await run(resolvedOptions);
|
|
7327
7403
|
}
|
|
7328
7404
|
export {
|