generated from blueplum/typescript-template
chore: npm best practices
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@ import * as esbuild from "esbuild";
|
||||
|
||||
const result = await esbuild.build({
|
||||
entryPoints: ["src/index.ts", "src/config.ts"],
|
||||
minify: true,
|
||||
minify: false,
|
||||
bundle: true,
|
||||
outdir: "dist",
|
||||
define: {
|
||||
|
||||
@@ -12,6 +12,8 @@ dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
tests/generated/
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 BluePlum
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -2,5 +2,6 @@ import { defineConfig } from "./dist/config";
|
||||
|
||||
export default defineConfig({
|
||||
include: ["src/**.ts"],
|
||||
outDir: "tests/generated",
|
||||
templateHeader: ["console.log('hello, world!');"],
|
||||
});
|
||||
|
||||
+8
-6
@@ -1,25 +1,27 @@
|
||||
{
|
||||
"name": "gen-doctests",
|
||||
"description": "Tool for generating tests from JSDoc @example:s for various test harnesses",
|
||||
"keywords": ["tool", "docs", "test", "doctest"],
|
||||
"private": false,
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.2",
|
||||
"type": "module",
|
||||
"bin": "dist/index.js",
|
||||
"scripts": {
|
||||
"test": "vitest --run --reporter=tree",
|
||||
"build": "tsc -b && node .config/build.js",
|
||||
"prepublishOnly": "pnpm build",
|
||||
"prepack": "pnpm build",
|
||||
"fmt": "prettier --write .",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"default": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts"
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./config": {
|
||||
"default": "./dist/config.js",
|
||||
"types": "./dist/config.d.ts"
|
||||
"types": "./dist/config.d.ts",
|
||||
"default": "./dist/config.js"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
+2
-2
@@ -188,9 +188,9 @@ export function createGenerator(options: Options) {
|
||||
node = regions[region];
|
||||
}
|
||||
|
||||
const out = fn(src, name) + "\n\n";
|
||||
const out = fn(src, name);
|
||||
if (node !== null) node[Symbol()] = out;
|
||||
else source += out;
|
||||
else source += out + "\n\n";
|
||||
}
|
||||
|
||||
function emitRegions(region: Region): string {
|
||||
|
||||
@@ -104,9 +104,17 @@ async function main() {
|
||||
function parseWithOptions(options: Options) {
|
||||
const doctest = picomatch("**/*" + options.fileExtension + ".*");
|
||||
|
||||
/**
|
||||
* @example
|
||||
* Test 1
|
||||
*/
|
||||
const files = globSync(options.include)
|
||||
.filter((v) => !doctest(v))
|
||||
.filter((path) => !lstatSync(path).isDirectory());
|
||||
/**
|
||||
* @example
|
||||
* Test 2
|
||||
*/
|
||||
const parsed = files
|
||||
.map((path) => parseFile(path, options))
|
||||
.filter((v) => v !== null);
|
||||
|
||||
Reference in New Issue
Block a user