Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/open-pears-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nodesecure/tarball": minor
---

Integrate support of TypeScript source files
2 changes: 1 addition & 1 deletion workspaces/scanner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@nodesecure/contact": "^3.0.0",
"@nodesecure/flags": "^3.0.3",
"@nodesecure/i18n": "^4.0.2",
"@nodesecure/js-x-ray": "11.0.1",
"@nodesecure/js-x-ray": "11.1.0",
"@nodesecure/mama": "^2.0.2",
"@nodesecure/npm-registry-sdk": "^4.4.0",
"@nodesecure/npm-types": "^1.3.0",
Expand Down
2 changes: 1 addition & 1 deletion workspaces/tarball/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"dependencies": {
"@nodesecure/conformance": "^1.2.0",
"@nodesecure/fs-walk": "^2.0.0",
"@nodesecure/js-x-ray": "11.0.1",
"@nodesecure/js-x-ray": "11.1.0",
"@nodesecure/mama": "^2.0.0",
"@nodesecure/npm-types": "^1.2.0",
"@nodesecure/utils": "^2.3.0",
Expand Down
4 changes: 3 additions & 1 deletion workspaces/tarball/src/class/NpmTarball.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export interface ScannedFilesResult {

export class NpmTarball {
static JS_EXTENSIONS = new Set([
".js", ".mjs", ".cjs"
".js", ".mjs", ".cjs",
".ts", ".mts", ".cts",
".jsx", ".tsx"
]);

manifest: LocatedManifestManager;
Expand Down
40 changes: 40 additions & 0 deletions workspaces/tarball/test/SourceCodeScanner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,46 @@ describe("SourceCodeScanner", () => {
]
);
});

test("iterate() should report typescript files", async() => {
const mama = loadFixtureManifest("tsOnly");
const astAnalyser = new AstAnalyser();
const aggregator = createAggregator();

const scanner = new SourceCodeScanner(mama, {
reportInitiator: () => aggregator,
astAnalyser
});
await scanner.iterate({
manifest: [
"src/index.ts"
],
javascript: []
});

const { reports } = aggregator;

const firstReport = reports[0];
if (firstReport.ok) {
assert.ok(firstReport.dependencies.has("node:http"));
assert.ok(firstReport.dependencies.has("./bar.ts"));
}
else {
assert.fail("First report should be ok");
}

const files = reports
.map((report) => path.normalize(report.file))
.sort();

assert.deepEqual(
files,
[
"src\\index.ts",
"src\\bar.ts"
].sort()
);
});
});

function loadFixtureManifest(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "foobar",
"main": "./src/index.ts"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const foo = "hello world";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import http from "node:http";
import { foo } from "./bar.ts";
console.log(foo);
Loading