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({
|
const result = await esbuild.build({
|
||||||
entryPoints: ["src/index.ts", "src/config.ts"],
|
entryPoints: ["src/index.ts", "src/config.ts"],
|
||||||
minify: true,
|
minify: false,
|
||||||
bundle: true,
|
bundle: true,
|
||||||
outdir: "dist",
|
outdir: "dist",
|
||||||
define: {
|
define: {
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ dist
|
|||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.local
|
||||||
|
|
||||||
|
tests/generated/
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
!.vscode/extensions.json
|
!.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({
|
export default defineConfig({
|
||||||
include: ["src/**.ts"],
|
include: ["src/**.ts"],
|
||||||
|
outDir: "tests/generated",
|
||||||
templateHeader: ["console.log('hello, world!');"],
|
templateHeader: ["console.log('hello, world!');"],
|
||||||
});
|
});
|
||||||
|
|||||||
+8
-6
@@ -1,25 +1,27 @@
|
|||||||
{
|
{
|
||||||
"name": "gen-doctests",
|
"name": "gen-doctests",
|
||||||
|
"description": "Tool for generating tests from JSDoc @example:s for various test harnesses",
|
||||||
|
"keywords": ["tool", "docs", "test", "doctest"],
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": "dist/index.js",
|
"bin": "dist/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "vitest --run --reporter=tree",
|
"test": "vitest --run --reporter=tree",
|
||||||
"build": "tsc -b && node .config/build.js",
|
"build": "tsc -b && node .config/build.js",
|
||||||
"prepublishOnly": "pnpm build",
|
"prepack": "pnpm build",
|
||||||
"fmt": "prettier --write .",
|
"fmt": "prettier --write .",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"default": "./dist/index.js",
|
"types": "./dist/index.d.ts",
|
||||||
"types": "./dist/index.d.ts"
|
"default": "./dist/index.js"
|
||||||
},
|
},
|
||||||
"./config": {
|
"./config": {
|
||||||
"default": "./dist/config.js",
|
"types": "./dist/config.d.ts",
|
||||||
"types": "./dist/config.d.ts"
|
"default": "./dist/config.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
+2
-2
@@ -188,9 +188,9 @@ export function createGenerator(options: Options) {
|
|||||||
node = regions[region];
|
node = regions[region];
|
||||||
}
|
}
|
||||||
|
|
||||||
const out = fn(src, name) + "\n\n";
|
const out = fn(src, name);
|
||||||
if (node !== null) node[Symbol()] = out;
|
if (node !== null) node[Symbol()] = out;
|
||||||
else source += out;
|
else source += out + "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitRegions(region: Region): string {
|
function emitRegions(region: Region): string {
|
||||||
|
|||||||
@@ -104,9 +104,17 @@ async function main() {
|
|||||||
function parseWithOptions(options: Options) {
|
function parseWithOptions(options: Options) {
|
||||||
const doctest = picomatch("**/*" + options.fileExtension + ".*");
|
const doctest = picomatch("**/*" + options.fileExtension + ".*");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @example
|
||||||
|
* Test 1
|
||||||
|
*/
|
||||||
const files = globSync(options.include)
|
const files = globSync(options.include)
|
||||||
.filter((v) => !doctest(v))
|
.filter((v) => !doctest(v))
|
||||||
.filter((path) => !lstatSync(path).isDirectory());
|
.filter((path) => !lstatSync(path).isDirectory());
|
||||||
|
/**
|
||||||
|
* @example
|
||||||
|
* Test 2
|
||||||
|
*/
|
||||||
const parsed = files
|
const parsed = files
|
||||||
.map((path) => parseFile(path, options))
|
.map((path) => parseFile(path, options))
|
||||||
.filter((v) => v !== null);
|
.filter((v) => v !== null);
|
||||||
|
|||||||
Reference in New Issue
Block a user