Skip to content

Commit

Permalink
chore: update to node 16
Browse files Browse the repository at this point in the history
  • Loading branch information
ipcjs committed Aug 4, 2024
1 parent 82412de commit 616b70c
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 38 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.nyc_output
.vscode
# .vscode
coverage
node_modules
dist
Expand All @@ -15,4 +15,5 @@ __debug
release-builds
conversion.log
error.log
bckp/
bckp/
*.cpuprofile
28 changes: 8 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"zip-a-folder": "2.0.0"
},
"engines": {
"node": ">=10.18.1",
"node": ">=16",
"npm": ">=5.6.0"
},
"repository": {
Expand All @@ -91,7 +91,7 @@
"@types/marked": "1.1.0",
"@types/minimist": "1.2.0",
"@types/mocha": "7.0.2",
"@types/node": "12.12.6",
"@types/node": "^16.0.0",
"@types/parse5": "7.0.0",
"@types/proxyquire": "1.3.28",
"@types/showdown": "1.9.3",
Expand Down
5 changes: 3 additions & 2 deletions src/dropTheRope.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env node --max-old-space-size=1024
/* istanbul ignore file */
// tslint:disable:no-console

import * as dropTheRopeRunner from './dropTheRopeRunner';
import { profileFn, timeFn } from './utils/logger';

// profileFn(() => dropTheRopeRunner.run({}))
// timeFn(() => dropTheRopeRunner.run({}))
dropTheRopeRunner.run({});
// tslint:enable:no-console
4 changes: 2 additions & 2 deletions src/utils/apply-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const applyLinks = (options: YarleOptions, outputNotebookFolders: Array<s
return path.extname(file).toLowerCase() === extension;
});
for (const targetFile of targetFiles) {
const fileContent = fs.readFileSync(`${notebookFolder}${path.sep}${targetFile}`, 'UTF-8');
const fileContent = fs.readFileSync(`${notebookFolder}${path.sep}${targetFile}`, 'utf-8');
let updatedContent = fileContent;
if (isTanaOutput()) {
const tanaNote = JSON.parse(updatedContent)
Expand Down Expand Up @@ -124,7 +124,7 @@ export const applyLinks = (options: YarleOptions, outputNotebookFolders: Array<s
const unrecognizable = "Unrecognizable";

for (const targetFile of allconvertedFiles) {
const fileContent = fs.readFileSync(targetFile, 'UTF-8');
const fileContent = fs.readFileSync(targetFile, 'utf-8');

// TODO APPLY EVERNOTE LINK
const evernoteInternalLinkPlaceholderRegExp = new RegExp('<YARLE_EVERNOTE_LINK_PLACEHOLDER>', 'g');
Expand Down
2 changes: 1 addition & 1 deletion src/utils/file-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const writeFile = (absFilePath: string, noteContent: string, pureNoteData
if (isLogseqJournal(yarleOptions) && fs.existsSync(absFilePath)){
// put the title as a first line
const compoundJournalNoteTitle = `# Journal Note for ${getCreationTime(pureNoteData)}`
const currentContent = fs.readFileSync(absFilePath, 'UTF-8')
const currentContent = fs.readFileSync(absFilePath, 'utf-8')
if (!currentContent.startsWith(compoundJournalNoteTitle)){
const updatedContent = `${compoundJournalNoteTitle}\n\n${currentContent}`
fs.writeFileSync(absFilePath, updatedContent)
Expand Down
21 changes: 20 additions & 1 deletion src/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@ export const logger = createLogger({
// - Write all logs error (and below) to `quick-start-error.log`.
//
new transports.File({ filename: path.join(__dirname, 'error.log'), level: 'error' }),
new transports.File({ filename: path.join(__dirname, 'conversion.log'), options: { flags: 'w' }}),
new transports.File({ filename: path.join(__dirname, 'conversion.log'), options: { flags: 'w' } }),
],
});


export async function profileFn<R>(block: () => Promise<R>, label?: string) {
console.profile(label)
return block()
.then((r) => {
console.profileEnd(label)
return r
})
}

export async function timeFn<R>(block: () => Promise<R>, label?: string) {
console.time(label)
return block()
.then((r) => {
console.timeEnd(label)
return r
})
}
4 changes: 2 additions & 2 deletions src/utils/tana/create-tana-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const createTanaOutput = (options: YarleOptions, outputNotebookFolders: A
for (const convertedFile of allconvertedFiles){
// load and parse mergedTanaNotes, or create if
const mergedNotes = getMergedTanaNotes(options)
const convertedTanaNote = JSON.parse(fs.readFileSync(convertedFile, 'UTF-8'))
const convertedTanaNote = JSON.parse(fs.readFileSync(convertedFile, 'utf-8'))

updateMergedNotes(mergedNotes, convertedTanaNote)
saveMergedTanaNotes(options, mergedNotes)
Expand Down Expand Up @@ -113,7 +113,7 @@ const getMergedTanaNotes = (options: YarleOptions): TanaIntermediateFile => {

let mergedTanaNote
try {
mergedTanaNote = JSON.parse(fs.readFileSync(`${options.outputDir}/${tanaNoteFileName}`, 'UTF-8'))
mergedTanaNote = JSON.parse(fs.readFileSync(`${options.outputDir}/${tanaNoteFileName}`, 'utf-8'))
}catch(error){
mergedTanaNote = createNewTanaFile()
}
Expand Down
14 changes: 8 additions & 6 deletions src/yarle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import { YarleOptions } from './YarleOptions';
import { processNode } from './process-node';
import { isWebClip } from './utils/note-utils';
import { loggerInfo } from './utils/loggerInfo';
import { hasAnyTagsInTemplate,
import {
hasAnyTagsInTemplate,
hasCreationTimeInTemplate,
hasLinkToOriginalInTemplate,
hasLocationInTemplate,
hasNotebookInTemplate,
hasSourceURLInTemplate,
hasUpdateTimeInTemplate } from './utils/templates/checker-functions';
hasUpdateTimeInTemplate
} from './utils/templates/checker-functions';
import { defaultTemplate } from './utils/templates/default-template';
import { OutputFormat } from './output-format';
import { clearLogFile } from './utils/clearLogFile';
Expand Down Expand Up @@ -69,7 +71,7 @@ export let yarleOptions: YarleOptions = { ...defaultYarleOptions };
const setOptions = (options: YarleOptions): void => {
yarleOptions = merge({}, defaultYarleOptions, options);

let template = (yarleOptions.templateFile) ? fs.readFileSync(yarleOptions.templateFile, 'utf-8') : defaultTemplate;
let template = (yarleOptions.templateFile) ? fs.readFileSync(yarleOptions.templateFile, 'utf-8') : defaultTemplate;
template = yarleOptions.currentTemplate ? yarleOptions.currentTemplate : template;

/*if (yarleOptions.templateFile) {*/
Expand Down Expand Up @@ -144,12 +146,12 @@ export const parseStream = async (options: YarleOptions, enexSource: string): Pr
for (const task of Object.keys(tasks)) {

const taskPlaceholder = `<YARLE-EN-V10-TASK>${task}</YARLE-EN-V10-TASK>`
const fileContent = fs.readFileSync(currentNotePath, 'UTF-8');
const fileContent = fs.readFileSync(currentNotePath, 'utf-8');
const sortedTasks = new Map([...tasks[task]].sort());

let updatedContent = fileContent.replace(taskPlaceholder, [...sortedTasks.values()].join('\n'));

const languageFactory = new LanguageFactory();
const languageFactory = new LanguageFactory();
const language = languageFactory.createLanguage(yarleOptions.outputFormat)
updatedContent = language.tagProcess(fileContent, sortedTasks, taskPlaceholder, updatedContent)

Expand All @@ -159,7 +161,7 @@ export const parseStream = async (options: YarleOptions, enexSource: string): Pr
}
});

xml.on('tag:task', (pureTask: any) => {
xml.on('tag:task', (pureTask: any) => {
const task = mapEvernoteTask(pureTask);
if (!tasks[task.taskgroupnotelevelid]) {
tasks[task.taskgroupnotelevelid] = new Map();
Expand Down

0 comments on commit 616b70c

Please sign in to comment.