Comparing version 0.3.0 to 0.4.0
@@ -1,2 +0,2 @@ | ||
#!/usr/bin/env node | ||
export {}; |
#!/usr/bin/env node | ||
import { deno2node, emitAndExit } from "./mod.js"; | ||
import { ts } from "./deps.node.js"; | ||
import { deno2node, emit } from "./mod.js"; | ||
import { Deno } from "./shim.node.js"; | ||
@@ -8,2 +9,9 @@ if (Deno.args.length !== 1 || Deno.args[0].startsWith("-")) { | ||
} | ||
emitAndExit(deno2node(Deno.args[0])); | ||
const project = deno2node(Deno.args[0]); | ||
const diagnostics = await emit(project); | ||
if (diagnostics.length !== 0) { | ||
console.info(project.formatDiagnosticsWithColorAndContext(diagnostics)); | ||
console.info("TypeScript", ts.version); | ||
console.info(`Found ${diagnostics.length} errors.`); | ||
Deno.exit(1); | ||
} |
@@ -8,4 +8,7 @@ import { Project } from "./deps.node.js"; | ||
}; | ||
/** | ||
* Synchronously loads `tsconfig.json` and `"files"`. | ||
*/ | ||
constructor(tsConfigFilePath: string); | ||
resolve(path_: string): string; | ||
} |
@@ -6,2 +6,5 @@ import { path, Project, ts, z } from "./deps.node.js"; | ||
export class Context { | ||
/** | ||
* Synchronously loads `tsconfig.json` and `"files"`. | ||
*/ | ||
constructor(tsConfigFilePath) { | ||
@@ -15,3 +18,2 @@ var _a; | ||
inlineSourceMap: false, | ||
noEmitOnError: true, | ||
sourceMap: false, | ||
@@ -18,0 +20,0 @@ strict: true, |
@@ -11,9 +11,2 @@ // based on https://github.com/dsherret/code-block-writer/blob/99454249cd13bd89befa45ac815b37b3e02896f5/scripts/build_npm.ts | ||
} | ||
function transpileShebang(sourceFile) { | ||
const regex = /^#!\/usr\/bin\/env -S deno run\b[^\n]*/; | ||
const match = regex.exec(sourceFile.getFullText()); | ||
if (match !== null) { | ||
sourceFile.replaceText([0, match[0].length], "#!/usr/bin/env node"); | ||
} | ||
} | ||
function transpileImportSpecifiers(sourceFile) { | ||
@@ -56,5 +49,4 @@ for (const statement of sourceFile.getStatements()) { | ||
shim(sourceFile); | ||
transpileShebang(sourceFile); | ||
} | ||
return ctx.project; | ||
} |
import { Deno } from "./shim.node.js"; | ||
export function emitAndExit(project) { | ||
const result = project.emitSync(); | ||
const diagnostics = result.getDiagnostics(); | ||
function diagnoze(project, diagnostics) { | ||
if (diagnostics.length === 0) | ||
return Deno.exit(0); | ||
return; | ||
console.info(project.formatDiagnosticsWithColorAndContext(diagnostics)); | ||
@@ -11,1 +9,7 @@ console.info(`Found ${diagnostics.length} errors.`); | ||
} | ||
export function emitAndExit(project) { | ||
const result = project.emitSync(); | ||
diagnoze(project, project.getPreEmitDiagnostics()); | ||
diagnoze(project, result.getDiagnostics()); | ||
return Deno.exit(0); | ||
} |
@@ -1,2 +0,2 @@ | ||
export * from "./deno2node.js"; | ||
export { emitAndExit } from "./emit_and_exit.js"; | ||
export { deno2node } from "./deno2node.js"; | ||
export { emit } from "./emit.js"; |
@@ -1,2 +0,2 @@ | ||
export * from "./deno2node.js"; | ||
export { emitAndExit } from "./emit_and_exit.js"; | ||
export { deno2node } from "./deno2node.js"; | ||
export { emit } from "./emit.js"; |
@@ -0,4 +1,10 @@ | ||
/// <reference types="node" /> | ||
import { chmod } from "fs/promises"; | ||
export declare const Deno: { | ||
args: string[]; | ||
build: { | ||
os: string; | ||
}; | ||
chmod: typeof chmod; | ||
exit: (code?: number | undefined) => never; | ||
args: string[]; | ||
}; |
// Node-only, see https://github.com/wojpawlik/deno2node/#preparing-your-project | ||
// deno-lint-ignore-file | ||
import { chmod } from "fs/promises"; | ||
const os = process.platform === "win32" ? "windows" : process.platform; | ||
export const Deno = { | ||
// please keep sorted | ||
args: process.argv.slice(2), | ||
build: { os }, | ||
chmod, | ||
exit: process.exit, | ||
args: process.argv.slice(2), | ||
}; |
{ | ||
"name": "deno2node", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Transpiles Deno projects into `.js` and `.d.ts` for Node.js.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
# deno2node | ||
<a href="https://doc.deno.land/https/raw.githubusercontent.com/wojpawlik/deno2node/v0.3.0/src/mod.ts"><img src="https://doc.deno.land/badge.svg" alt="deno doc"></a> | ||
<a href="https://doc.deno.land/https/raw.githubusercontent.com/wojpawlik/deno2node/main/src/mod.ts"><img src="https://doc.deno.land/badge.svg" alt="deno doc"></a> | ||
@@ -41,3 +41,3 @@ Transpiles Deno projects into `.js` and `.d.ts` for Node.js. | ||
[`deps.node.ts`]: https://github.com/wojpawlik/deno2node/v0.3.0/main/src/deps.node.ts | ||
[`shim.node.ts`]: https://github.com/wojpawlik/deno2node/v0.3.0/main/src/shim.node.ts | ||
[`deps.node.ts`]: https://github.com/wojpawlik/deno2node/blob/main/src/deps.node.ts | ||
[`shim.node.ts`]: https://github.com/wojpawlik/deno2node/blob/main/src/shim.node.ts |
#!/usr/bin/env -S deno run --unstable --allow-read --allow-write | ||
import { deno2node, emitAndExit } from "./mod.ts"; | ||
import { ts } from "./deps.deno.ts"; | ||
import { deno2node, emit } from "./mod.ts"; | ||
@@ -9,2 +10,9 @@ if (Deno.args.length !== 1 || Deno.args[0].startsWith("-")) { | ||
emitAndExit(deno2node(Deno.args[0])); | ||
const project = deno2node(Deno.args[0]); | ||
const diagnostics = await emit(project); | ||
if (diagnostics.length !== 0) { | ||
console.info(project.formatDiagnosticsWithColorAndContext(diagnostics)); | ||
console.info("TypeScript", ts.version); | ||
console.info(`Found ${diagnostics.length} errors.`); | ||
Deno.exit(1); | ||
} |
@@ -11,2 +11,5 @@ import { path, Project, ts, z } from "./deps.deno.ts"; | ||
/** | ||
* Synchronously loads `tsconfig.json` and `"files"`. | ||
*/ | ||
constructor(private readonly tsConfigFilePath: string) { | ||
@@ -18,3 +21,2 @@ this.project = new Project({ | ||
inlineSourceMap: false, // doesn't reflect deno2node transforms | ||
noEmitOnError: true, // for diagnostics | ||
sourceMap: false, // doesn't reflect deno2node transforms | ||
@@ -21,0 +23,0 @@ strict: true, |
@@ -13,10 +13,2 @@ // based on https://github.com/dsherret/code-block-writer/blob/99454249cd13bd89befa45ac815b37b3e02896f5/scripts/build_npm.ts | ||
function transpileShebang(sourceFile: SourceFile) { | ||
const regex = /^#!\/usr\/bin\/env -S deno run\b[^\n]*/; | ||
const match = regex.exec(sourceFile.getFullText()); | ||
if (match !== null) { | ||
sourceFile.replaceText([0, match[0].length], "#!/usr/bin/env node"); | ||
} | ||
} | ||
function transpileImportSpecifiers(sourceFile: SourceFile) { | ||
@@ -68,5 +60,4 @@ for (const statement of sourceFile.getStatements()) { | ||
shim(sourceFile); | ||
transpileShebang(sourceFile); | ||
} | ||
return ctx.project; | ||
} |
@@ -1,2 +0,2 @@ | ||
export * from "./deno2node.ts"; | ||
export { emitAndExit } from "./emit_and_exit.ts"; | ||
export { deno2node } from "./deno2node.ts"; | ||
export { emit } from "./emit.ts"; |
// Node-only, see https://github.com/wojpawlik/deno2node/#preparing-your-project | ||
// deno-lint-ignore-file | ||
import { chmod } from "fs/promises"; | ||
const os = process.platform === "win32" ? "windows" : process.platform; | ||
export const Deno = { | ||
// please keep sorted | ||
args: process.argv.slice(2), | ||
build: { os }, | ||
chmod, | ||
exit: process.exit, | ||
args: process.argv.slice(2), | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15791
27
332
0
1