Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@benev/turtle

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@benev/turtle - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

s/build/build_webpage.ts

5

package.json
{
"name": "@benev/turtle",
"version": "0.1.0",
"version": "0.1.1",
"description": "static site generator",

@@ -15,5 +15,6 @@ "license": "MIT",

"scripts": {
"build": "run-s clean compile",
"build": "run-s clean compile permissions",
"clean": "rm -rf x && mkdir x",
"compile": "tsc",
"permissions": "chmod +x x/cli.js",
"start": "http-server x/demo",

@@ -20,0 +21,0 @@ "watch": "tsc -w",

18

s/build/parts/write_webpage.ts
import {join, dirname, normalize, resolve} from "path"
import {join, resolve} from "path"
import {Path} from "../../utils/path.js"
import {untab} from "../../html/untab.js"
import {debase_path} from "./debase_path.js"

@@ -27,10 +28,7 @@ import {OutputLogger} from "../types/loggers.js"

const template_path = normalize(join(
dirname(path.relative),
destination,
))
const template_path = path.relative
const basics = make_template_basics({
template_path,
output_directory: output_directory,
output_directory,
input_directory: path.directory,

@@ -41,13 +39,15 @@ })

const result_html = await template_function.render()
const final_html = untab(result_html).trim()
const partial = debase_path(output_directory, destination)
const final_destination: Path = {
directory: output_directory,
relative: template_path,
relative: join(output_directory, partial),
absolute: resolve(template_path),
partial: debase_path(output_directory, template_path),
partial,
}
await write_file(final_destination.relative, result_html)
await write_file(final_destination.relative, final_html)
on_file_written(path, final_destination)
}
import {Path} from "../../utils/path.js"
import {build_webpage} from "../webpage.js"
import {OutputLogger} from "../types/loggers.js"
import {build_webpage} from "../build_webpage.js"
import {log_error} from "../../utils/log_error.js"

@@ -15,8 +16,15 @@ export async function build_all_webpages<xContext extends {}>(

paths.map(
async path => build_webpage(
path,
output_directory,
context,
on_file_written,
)
async path => {
try {
await build_webpage(
path,
output_directory,
context,
on_file_written,
)
}
catch (error) {
log_error(error, "rendering", path.relative)
}
}
)

@@ -23,0 +31,0 @@ )

import { log_error } from "../../utils/log_error.js"
import {Path} from "../../utils/path.js"

@@ -14,3 +15,10 @@ import {copy_file} from "../parts/copy_file.js"

paths.map(
async path => copy_file(path, output_directory, on_file_copied)
async path => {
try {
await copy_file(path, output_directory, on_file_copied)
}
catch (error) {
log_error(error, "copying", path.relative)
}
}
)

@@ -17,0 +25,0 @@ )

import {Path} from "../../utils/path.js"
import {log_error} from "../../utils/log_error.js"
import {ScriptMeta} from "../types/script_meta.js"

@@ -14,27 +15,39 @@ import {write_webpage} from "../parts/write_webpage.js"

await Promise.all(
paths.map(
async path => {
const script = await import(path.absolute)
const meta: ScriptMeta = {
const handy_write_webpage = (path: Path): ScriptMeta["write_webpage"] => (
async({template, context, destination}) => {
try {
await write_webpage<typeof context>({
path,
context,
template,
destination,
on_file_written,
output_directory,
write_webpage: async({template, context, destination}) => {
await write_webpage<typeof context>({
path,
output_directory,
context,
template,
destination,
on_file_written,
})
},
}
await script.default(meta)
on_turtle_script_executed(path)
})
}
)
catch (error) {
log_error(error, "rendering", destination)
}
}
)
async function execute_script(path: Path) {
try {
const script = await import(path.absolute)
const meta: ScriptMeta = {
path,
on_file_written,
output_directory,
write_webpage: handy_write_webpage(path),
}
await script.default(meta)
on_turtle_script_executed(path)
}
catch (error) {
log_error(error, "executing", path.relative)
}
}
await Promise.all(paths.map(execute_script))
}

@@ -5,3 +5,3 @@ #!/usr/bin/env node

import {cli, color} from "@benev/argv"
import {build_website} from "./build/website.js"
import {build_website} from "./build/build_website.js"
import {WebsiteLoggers} from "./build/types/loggers.js"

@@ -8,0 +8,0 @@

export class HashVersionerError extends Error {
name = this.constructor.name
constructor(message: string) {
super(message)
}
}
export * from "./build/turtle_script.js"
export * from "./build/website.js"
export * from "./build/webpage.js"
export * from "./build/build_website.js"
export * from "./build/build_webpage.js"

@@ -24,5 +24,7 @@ export * from "./build/types/loggers.js"

export * from "./utils/hash_versioner.js"
export * from "./utils/indent.js"
export * from "./utils/nap.js"
export * from "./utils/path.js"
export * from "./utils/repeat_string.js"
export * from "./utils/write_file.js"

@@ -1,2 +0,3 @@

import { join, dirname, normalize, resolve } from "path";
import { join, resolve } from "path";
import { untab } from "../../html/untab.js";
import { debase_path } from "./debase_path.js";

@@ -6,6 +7,6 @@ import { write_file } from "../../utils/write_file.js";

export async function write_webpage({ path, context, destination, output_directory, template, on_file_written, }) {
const template_path = normalize(join(dirname(path.relative), destination));
const template_path = path.relative;
const basics = make_template_basics({
template_path,
output_directory: output_directory,
output_directory,
input_directory: path.directory,

@@ -15,11 +16,13 @@ });

const result_html = await template_function.render();
const final_html = untab(result_html).trim();
const partial = debase_path(output_directory, destination);
const final_destination = {
directory: output_directory,
relative: template_path,
relative: join(output_directory, partial),
absolute: resolve(template_path),
partial: debase_path(output_directory, template_path),
partial,
};
await write_file(final_destination.relative, result_html);
await write_file(final_destination.relative, final_html);
on_file_written(path, final_destination);
}
//# sourceMappingURL=write_webpage.js.map

@@ -1,5 +0,13 @@

import { build_webpage } from "../webpage.js";
import { build_webpage } from "../build_webpage.js";
import { log_error } from "../../utils/log_error.js";
export async function build_all_webpages(paths, output_directory, context, on_file_written) {
await Promise.all(paths.map(async (path) => build_webpage(path, output_directory, context, on_file_written)));
await Promise.all(paths.map(async (path) => {
try {
await build_webpage(path, output_directory, context, on_file_written);
}
catch (error) {
log_error(error, "rendering", path.relative);
}
}));
}
//# sourceMappingURL=build_all_webpages.js.map

@@ -0,5 +1,13 @@

import { log_error } from "../../utils/log_error.js";
import { copy_file } from "../parts/copy_file.js";
export async function copy_all_files(paths, output_directory, on_file_copied) {
await Promise.all(paths.map(async (path) => copy_file(path, output_directory, on_file_copied)));
await Promise.all(paths.map(async (path) => {
try {
await copy_file(path, output_directory, on_file_copied);
}
catch (error) {
log_error(error, "copying", path.relative);
}
}));
}
//# sourceMappingURL=copy_all_files.js.map

@@ -0,24 +1,37 @@

import { log_error } from "../../utils/log_error.js";
import { write_webpage } from "../parts/write_webpage.js";
export async function run_all_turtle_scripts(paths, output_directory, on_file_written, on_turtle_script_executed) {
await Promise.all(paths.map(async (path) => {
const script = await import(path.absolute);
const meta = {
path,
on_file_written,
output_directory,
write_webpage: async ({ template, context, destination }) => {
await write_webpage({
path,
output_directory,
context,
template,
destination,
on_file_written,
});
},
};
await script.default(meta);
on_turtle_script_executed(path);
}));
const handy_write_webpage = (path) => (async ({ template, context, destination }) => {
try {
await write_webpage({
path,
context,
template,
destination,
on_file_written,
output_directory,
});
}
catch (error) {
log_error(error, "rendering", destination);
}
});
async function execute_script(path) {
try {
const script = await import(path.absolute);
const meta = {
path,
on_file_written,
output_directory,
write_webpage: handy_write_webpage(path),
};
await script.default(meta);
on_turtle_script_executed(path);
}
catch (error) {
log_error(error, "executing", path.relative);
}
}
await Promise.all(paths.map(execute_script));
}
//# sourceMappingURL=run_all_turtle_scripts.js.map
#!/usr/bin/env node
var _a, _b, _c;
import { cli, color } from "@benev/argv";
import { build_website } from "./build/website.js";
import { build_website } from "./build/build_website.js";
const program_name = color.green("🐢 @benev/turtle");

@@ -6,0 +6,0 @@ const { params } = cli()({

export declare class HashVersionerError extends Error {
name: string;
constructor(message: string);
}
export class HashVersionerError extends Error {
constructor(message) {
super(message);
constructor() {
super(...arguments);
this.name = this.constructor.name;

@@ -5,0 +5,0 @@ }

export * from "./build/turtle_script.js";
export * from "./build/website.js";
export * from "./build/webpage.js";
export * from "./build/build_website.js";
export * from "./build/build_webpage.js";
export * from "./build/types/loggers.js";

@@ -19,4 +19,6 @@ export * from "./build/types/script_meta.js";

export * from "./utils/hash_versioner.js";
export * from "./utils/indent.js";
export * from "./utils/nap.js";
export * from "./utils/path.js";
export * from "./utils/repeat_string.js";
export * from "./utils/write_file.js";
export * from "./build/turtle_script.js";
export * from "./build/website.js";
export * from "./build/webpage.js";
export * from "./build/build_website.js";
export * from "./build/build_webpage.js";
export * from "./build/types/loggers.js";

@@ -19,5 +19,7 @@ export * from "./build/types/script_meta.js";

export * from "./utils/hash_versioner.js";
export * from "./utils/indent.js";
export * from "./utils/nap.js";
export * from "./utils/path.js";
export * from "./utils/repeat_string.js";
export * from "./utils/write_file.js";
//# sourceMappingURL=index.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc