Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: Clean up files in repo #2963

Merged
merged 19 commits into from Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -3,5 +3,7 @@
node_modules/
test/compiled_tests
public
lib
docs/LICENSE.md
vuln.js
man/marked.1
UziTech marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 0 additions & 15 deletions Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions component.json

This file was deleted.

10 changes: 6 additions & 4 deletions build-docs.js → docs/build.js
@@ -1,6 +1,7 @@
/* global marked */
import '../marked.min.js';
import { promises } from 'fs';
import { join, dirname, parse, format } from 'path';
import { Marked } from './lib/marked.esm.js';
import { markedHighlight } from 'marked-highlight';
import { HighlightJS } from 'highlight.js';
import titleize from 'titleize';
Expand All @@ -13,7 +14,7 @@ const outputDir = join(cwd, 'public');
const templateFile = join(inputDir, '_document.html');
const isUppercase = str => /[A-Z_]+/.test(str);
const getTitle = str => str === 'INDEX' ? '' : titleize(str.replace(/_/g, ' ')) + ' - ';
const marked = new Marked(markedHighlight((code, language) => {
const markedInstance = new marked.Marked(markedHighlight((code, language) => {
if (!language) {
return highlightAuto(code).value;
}
Expand All @@ -24,6 +25,8 @@ async function init() {
console.log('Cleaning up output directory ' + outputDir);
await rm(outputDir, { force: true, recursive: true });
await mkdir(outputDir);
console.log(`Copying file ${join(cwd, 'LICENSE.md')}`);
console.log(` to ${join(inputDir, 'LICENSE.md')}`);
await copyFile(join(cwd, 'LICENSE.md'), join(inputDir, 'LICENSE.md'));
Copy link
Member

@styfle styfle Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add something like:

await copyFile(join(cwd, 'marked.min.js'), join(outputDir, 'marked.min.js''));

Then in the client side JS of the Demo, you can fetch the latest for the given deployment with:

fetch(new URL('/marked.min.js', window.location))`

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to get the PR vercel link with just a PR#?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it based on the vercel comment View Preview link

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or we don't even need the pr version because now we can go to the preview and use /marked.min.js

Copy link
Member

@styfle styfle Sep 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, we don’t need a text input anymore. Either you select an old version or you select “HEAD”. And HEAD for a production deployment is master branch and for a preview deployment it’s the PR branch.

const tmpl = await readFile(templateFile, 'utf8');
console.log('Building markdown...');
Expand All @@ -45,7 +48,7 @@ async function build(currentDir, tmpl) {
let html = await readFile(filename, 'utf8');
const parsed = parse(filename);
if (parsed.ext === '.md' && isUppercase(parsed.name)) {
const mdHtml = marked.parse(html);
const mdHtml = markedInstance.parse(html);
html = tmpl
.replace('<!--{{title}}-->', getTitle(parsed.name))
.replace('<!--{{content}}-->', mdHtml);
Expand All @@ -55,7 +58,6 @@ async function build(currentDir, tmpl) {
}
parsed.dir = parsed.dir.replace(inputDir, outputDir);
const outfile = format(parsed);
// console.log('Ensure directory ' + dirname(outfile));
await mkdir(dirname(outfile), { recursive: true });
console.log('Writing file ' + outfile);
await writeFile(outfile, html, { mode });
Expand Down