-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: migrate to TypeScript (#88)
* chore: migrate to ts * refactor: complete migration --------- Co-authored-by: fraxken <gentilhomme.thomas@gmail.com>
- Loading branch information
Showing
22 changed files
with
310 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { typescriptConfig } from "@openally/config.eslint"; | ||
|
||
export default typescriptConfig(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,58 @@ | ||
{ | ||
"name": "@nodesecure/flags", | ||
"version": "2.4.0", | ||
"description": "NodeSecure security flags", | ||
"scripts": { | ||
"test": "node --test test/", | ||
"coverage": "c8 -r html npm test", | ||
"lint": "eslint index.js", | ||
"generateFlags": "node scripts/generateFlags.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/NodeSecure/flags.git" | ||
}, | ||
"keywords": [ | ||
"nodesecure", | ||
"flags", | ||
"documentation" | ||
], | ||
"exports": { | ||
".": { | ||
"import": "./index.js" | ||
}, | ||
"./web": { | ||
"types": "./web.d.ts", | ||
"import": "./src/web.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"types": "./index.d.ts", | ||
"modes": { | ||
"web": "src/web.js" | ||
}, | ||
"author": "GENTILHOMME Thomas <gentilhomme.thomas@gmail.com>", | ||
"files": [ | ||
"index.d.ts", | ||
"index.js", | ||
"web.d.ts", | ||
"src", | ||
"FLAGS.md" | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/NodeSecure/flags/issues" | ||
}, | ||
"homepage": "https://github.com/NodeSecure/flags#readme", | ||
"devDependencies": { | ||
"@nodesecure/eslint-config": "^1.8.0", | ||
"c8": "^10.1.2", | ||
"eslint": "^9.9.0", | ||
"turndown": "^7.1.2" | ||
}, | ||
"type": "module", | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
} | ||
{ | ||
"name": "@nodesecure/flags", | ||
"version": "2.4.0", | ||
"description": "NodeSecure security flags", | ||
"scripts": { | ||
"test": "glob -c \"tsx --test\" \"./test/**/*.spec.ts\"", | ||
"coverage": "c8 -r html npm test", | ||
"lint": "eslint index.js", | ||
"generateFlags": "tsx scripts/generateFlags.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/NodeSecure/flags.git" | ||
}, | ||
"keywords": [ | ||
"nodesecure", | ||
"flags", | ||
"documentation" | ||
], | ||
"exports": { | ||
".": { | ||
"import": "./index.js" | ||
}, | ||
"./web": { | ||
"types": "./web.d.ts", | ||
"import": "./src/web.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"types": "./dist/index.d.ts", | ||
"modes": { | ||
"web": "src/web.js" | ||
}, | ||
"author": "GENTILHOMME Thomas <gentilhomme.thomas@gmail.com>", | ||
"files": [ | ||
"dist" | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/NodeSecure/flags/issues" | ||
}, | ||
"homepage": "https://github.com/NodeSecure/flags#readme", | ||
"devDependencies": { | ||
"@openally/config.eslint": "^1.0.0", | ||
"@openally/config.typescript": "^1.0.3", | ||
"@types/node": "^22.2.0", | ||
"@types/turndown": "^5.0.5", | ||
"c8": "^10.1.2", | ||
"glob": "^11.0.0", | ||
"tsx": "^4.17.0", | ||
"turndown": "^7.1.2", | ||
"typescript": "^5.5.4" | ||
}, | ||
"type": "module", | ||
"engines": { | ||
"node": ">=20" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Import Node.js Dependencies | ||
import path from "node:path"; | ||
import fs from "node:fs/promises"; | ||
import { fileURLToPath } from "node:url"; | ||
|
||
// Import Third-party Dependency | ||
import TurndownService from "turndown"; | ||
|
||
// CONSTANTS | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
const kRootPath = path.join(__dirname, ".."); | ||
|
||
const turndownService = new TurndownService(); | ||
|
||
turndownService.addRule("h1", { | ||
filter: "h1", | ||
replacement: (content) => `<summary>${content}</summary>` | ||
}); | ||
turndownService.addRule("div", { | ||
filter: "div", | ||
replacement: (content) => `<details>${content}</details>` | ||
}); | ||
|
||
const { flags, headerTemplate } = await loadHTMLs(); | ||
await fs.writeFile( | ||
path.join(kRootPath, "FLAGS.md"), | ||
headerTemplate.concat( | ||
turndownService.turndown(flags) | ||
) | ||
); | ||
|
||
async function loadHTMLs() { | ||
const HTMLFlagsLocation = path.join(kRootPath, "src", "flags"); | ||
const HTMLFlagsEntries = await fs.readdir(HTMLFlagsLocation); | ||
|
||
const [headerTemplate, ...HTMLFlagsFiles] = await Promise.all([ | ||
fs.readFile( | ||
path.join(__dirname, "template", "flagDocHeader.md"), | ||
"utf-8" | ||
), | ||
...HTMLFlagsEntries.map( | ||
(file) => fs.readFile(path.join(HTMLFlagsLocation, file), "utf-8") | ||
) | ||
]); | ||
|
||
return { | ||
flags: HTMLFlagsFiles.join(""), | ||
headerTemplate | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./node.js"; | ||
export * from "./web.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.