Skip to content

Commit

Permalink
fix: disable jsr published tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yohe-Am committed Dec 15, 2024
1 parent a872a6e commit 0eac780
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 11 deletions.
118 changes: 117 additions & 1 deletion deno.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/typegraph/deno/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
}
},
"exports": {
".": "./src/index.ts",
"./deps/_import.ts": "./src/deps/_import.ts",
"./deps/mod.ts": "./src/deps/mod.ts",
"./effects": "./src/effects.ts",
"./envs/cli": "./src/envs/cli.ts",
"./gen/typegraph_core.d.ts": "./src/gen/typegraph_core.d.ts",
"./gen/typegraph_core": "./src/gen/typegraph_core.d.ts",
"./host/host.d.ts": "./src/host/host.d.ts",
".": "./src/index.ts",
"./host/host": "./src/host/host.d.ts",
"./io": "./src/io.ts",
"./metagen": "./src/metagen.ts",
"./params": "./src/params.ts",
Expand Down
2 changes: 2 additions & 0 deletions src/typegraph/deno/src/deps/_import.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// no-auto-license-header | @generated (pre-commit doesn't support two headers)

// jsr-private-module

/*
The MIT License (MIT)
Expand Down
3 changes: 3 additions & 0 deletions src/typegraph/deno/src/deps/mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
// SPDX-License-Identifier: MPL-2.0

// jsr-private-module

export { caller } from "./_import.ts";

export function mapValues<
Expand Down
2 changes: 1 addition & 1 deletion src/typegraph/deno/src/typegraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export async function typegraph(
log.debug("exiting");
process.exit(0);
}
}, 100);
}, 1000);

Check warning on line 280 in src/typegraph/deno/src/typegraph.ts

View check run for this annotation

Codecov / codecov/patch

src/typegraph/deno/src/typegraph.ts#L280

Added line #L280 was not covered by tests
}

--counter;
Expand Down
12 changes: 9 additions & 3 deletions tests/e2e/published/published_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@ typegraphs:
prisma:
migrations_path: "migrations"
`);
await t.should("work with JSR npm", async () => {
// FIXME: enable after 0.5.0.-rc.8 releases
/* await t.should("work with JSR npm", async () => {
const npmJsrDir = await tgsDir.join("npm_jsr").ensureDir();
await $`pnpm init`.cwd(npmJsrDir);
await $`pnpm --package=jsr dlx jsr add @typegraph/sdk@${PUBLISHED_VERSION}`
Expand Down Expand Up @@ -451,7 +452,7 @@ typegraphs:
.env("PATH", `${metaBinDir}:${Deno.env.get("PATH")}`)
.env("MCLI_LOADER_CMD", `deno run -A --config deno.json`)
.env("RUST_LOG", "trace");
});
}); */

await t.should("work with pypa", async () => {
const pypaDir = await tgsDir.join("pypa").ensureDir();
Expand All @@ -462,7 +463,12 @@ typegraphs:
);
await $.co([
pypaDir.join("README.md").ensureFile(),
$`bash -c 'python3 -m venv .venv && source .venv/bin/activate && poetry install --no-root'`
$`bash -sx`
.stdinText([
`python3 -m venv .venv`,
`source .venv/bin/activate`,
`poetry install --no-root`,
].join("\n"))
.cwd(
pypaDir,
),
Expand Down
23 changes: 20 additions & 3 deletions tools/jsr/jsr-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ copyFilesAt(
);

// Prepare jsr export map
const jsrExports = {} as Record<string, string>;
const jsrExports = {
".": "./src/index.ts",
"./deps/_import.ts": "./src/deps/_import.ts",
"./deps/mod.ts": "./src/deps/mod.ts",
} as Record<string, string>;
for await (
const { path } of expandGlob("./**/*.*", {
root: srcDir,
includeDirs: false,
globstar: true,
exclude: [
"index.ts",
],
})
) {
if (/\.(ts|js|mjs)$/.test(path)) {
Expand All @@ -35,9 +42,12 @@ for await (
continue;
}
const hintFile = `${removeExtension(path)}.d.ts`;
const sourcePath = existsSync(hintFile) ? hintFile : path;
const sourcePath = await $.path(hintFile).exists() ? hintFile : path;
const canonRelPath = sourcePath.replace(denoSdkDir, ".");
const usrRelPath = sourcePath.replace(srcDir, ".");
const relPath = sourcePath.replace(srcDir, ".");
const usrRelPath = path.endsWith(".d.ts")
? relPath
: removeExtension(relPath);
jsrExports[usrRelPath] = canonRelPath;
}
}
Expand All @@ -53,6 +63,13 @@ Deno.writeTextFileSync(
publish: {
exclude: ["!src/gen", "!LICENSE.md", "!README.md"],
},
lint: {
rules: {
exclude: [
"no-external-import",
],
},
},
exports: jsrExports,
},
null,
Expand Down
1 change: 1 addition & 0 deletions tools/tasks/lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default {

const ignores = [
"tools/tasks-lock.ts",
".metatype",
...(await $.workingDir.resolve(".gitignore").readText())
.split("\n")
.map((l) => l.trim())
Expand Down
5 changes: 3 additions & 2 deletions tools/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ export function findCursors(
/** Remove extension, will treat `.d.ts` as a whole for example */
export function removeExtension(path: string) {
const known = /(\.d\.m?ts)$/;
return known.test(path.trim())
? path.replace(path, "")
const match = path.trim().match(known);
return match
? path.replace(match[0], "")

Check warning on line 118 in tools/utils.ts

View check run for this annotation

Codecov / codecov/patch

tools/utils.ts#L116-L118

Added lines #L116 - L118 were not covered by tests
: path.substring(0, path.lastIndexOf("."));
}

Expand Down

0 comments on commit 0eac780

Please sign in to comment.