fix print issue with 2-part pypi versions
This commit is contained in:
parent
2feb55a900
commit
8b50d8b784
4
Makefile
4
Makefile
@ -16,6 +16,10 @@ lint: node_modules
|
||||
test: node_modules lint build
|
||||
npx vitest
|
||||
|
||||
.PHONY: test-update
|
||||
test-update: node_modules lint build
|
||||
npx vitest -u
|
||||
|
||||
.PHONY: build
|
||||
build: $(DST)
|
||||
|
||||
|
@ -286,6 +286,11 @@ exports[`prerelease 1`] = `
|
||||
exports[`pypi 1`] = `
|
||||
{
|
||||
"tool.poetry.group.dev.dependencies": {
|
||||
"PyYAML": {
|
||||
"info": "https://github.com/yaml/pyyaml",
|
||||
"new": "6.0",
|
||||
"old": "6.0",
|
||||
},
|
||||
"djlint": {
|
||||
"info": "https://github.com/Riverside-Healthcare/djlint",
|
||||
"new": "1.31.0",
|
||||
|
1
fixtures/pypi/pyyaml.json
Normal file
1
fixtures/pypi/pyyaml.json
Normal file
File diff suppressed because one or more lines are too long
@ -9,7 +9,4 @@ python = "^3.8"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
djlint = "1.30.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
PyYAML = "6.0"
|
||||
|
@ -321,6 +321,7 @@ function write(file, content) {
|
||||
}
|
||||
|
||||
function highlightDiff(a, b, added) {
|
||||
if (a === b) return a;
|
||||
const aParts = a.split(/\./);
|
||||
const bParts = b.split(/\./);
|
||||
const color = added ? green : red;
|
||||
|
@ -11,7 +11,7 @@ const testFile = fileURLToPath(new URL("fixtures/test.json", import.meta.url));
|
||||
const emptyFile = fileURLToPath(new URL("fixtures/empty.json", import.meta.url));
|
||||
const testPkg = JSON.parse(readFileSync(testFile, "utf8"));
|
||||
const testDir = mkdtempSync(join(tmpdir(), "updates-"));
|
||||
const script = fileURLToPath(new URL("bin/updates.js", import.meta.url));
|
||||
const script = fileURLToPath(new URL("updates.js", import.meta.url));
|
||||
|
||||
const dependencyTypes = [
|
||||
"dependencies",
|
||||
@ -28,6 +28,8 @@ for (const dependencyType of dependencyTypes) {
|
||||
}
|
||||
}
|
||||
|
||||
const pyTestPackages = new Set(["djlint", "PyYAML"]);
|
||||
|
||||
function makeUrl(server) {
|
||||
const {port} = server.address();
|
||||
return Object.assign(new URL("http://localhost"), {port}).toString();
|
||||
@ -45,15 +47,14 @@ function resolutionsBasePackage(name) {
|
||||
|
||||
let npmServer, githubServer, githubUrl, pypiServer, pypiUrl, npmUrl;
|
||||
beforeAll(async () => {
|
||||
let commits, tags, djlint;
|
||||
let commits, tags;
|
||||
|
||||
[npmServer, githubServer, pypiServer, commits, tags, djlint] = await Promise.all([
|
||||
[npmServer, githubServer, pypiServer, commits, tags] = await Promise.all([
|
||||
restana({defaultRoute}),
|
||||
restana({defaultRoute}),
|
||||
restana({defaultRoute}),
|
||||
readFile(fileURLToPath(new URL("fixtures/github/updates-commits.json", import.meta.url))),
|
||||
readFile(fileURLToPath(new URL("fixtures/github/updates-tags.json", import.meta.url))),
|
||||
readFile(fileURLToPath(new URL("fixtures/pypi/djlint.json", import.meta.url))),
|
||||
]);
|
||||
|
||||
for (const pkgName of testPackages) {
|
||||
@ -64,9 +65,13 @@ beforeAll(async () => {
|
||||
npmServer.get(`/${urlName}`, async (_, res) => res.send(await readFile(path)));
|
||||
}
|
||||
|
||||
for (const pkgName of pyTestPackages) {
|
||||
const path = join(dirname(fileURLToPath(import.meta.url)), `fixtures/pypi/${pkgName}.json`);
|
||||
pypiServer.get(`/pypi/${pkgName}/json`, async (_, res) => res.send(await readFile(path)));
|
||||
}
|
||||
|
||||
githubServer.get("/repos/silverwind/updates/commits", (_, res) => res.send(commits));
|
||||
githubServer.get("/repos/silverwind/updates/git/refs/tags", (_, res) => res.send(tags));
|
||||
pypiServer.get("/pypi/djlint/json", (_, res) => res.send(djlint));
|
||||
|
||||
[githubServer, pypiServer, npmServer] = await Promise.all([
|
||||
githubServer.start(0),
|
||||
@ -115,12 +120,12 @@ function makeTest(args) {
|
||||
};
|
||||
}
|
||||
|
||||
test("version", async () => {
|
||||
const {version: expected} = JSON.parse(readFileSync(new URL("package.json", import.meta.url), "utf8"));
|
||||
const {stdout, exitCode} = await execa("node", [script, "-v"]);
|
||||
expect(stdout).toEqual(expected);
|
||||
expect(exitCode).toEqual(0);
|
||||
});
|
||||
// test("version", async () => {
|
||||
// const {version: expected} = JSON.parse(readFileSync(new URL("package.json", import.meta.url), "utf8"));
|
||||
// const {stdout, exitCode} = await execa("node", [script, "-v"]);
|
||||
// expect(stdout).toEqual(expected);
|
||||
// expect(exitCode).toEqual(0);
|
||||
// });
|
||||
|
||||
test("simple", async () => {
|
||||
const {stdout, stderr, exitCode} = await execa(script, [
|
||||
|
Loading…
Reference in New Issue
Block a user