Skip to content

Commit

Permalink
build: add/update build script aliases
Browse files Browse the repository at this point in the history
- add clean script
- add typedoc config files
  • Loading branch information
postspectacular committed Jan 4, 2025
1 parent 8fed055 commit 13a05a5
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/adapter-editart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"build": "node ../../tools/build.js src/index.ts adapter-editart",
"build:types": "tsc -d --emitDeclarationOnly --noEmit false",
"build:dist": "node ../../tools/build-dist.js",
"clean": "bun ../../tools/clean-package.js",
"doc": "typedoc",
"publish": "yarn npm publish --access public"
},
"dependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/adapter-editart/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"excludeProtected": true,
"excludePrivate": true,
"excludeInternal": true,
"out": "doc",
"entryPoints": ["src/index.ts"]
}
2 changes: 2 additions & 0 deletions packages/adapter-fxhash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"build": "node ../../tools/build.js src/index.ts adapter-fxhash",
"build:types": "tsc -d --emitDeclarationOnly --noEmit false",
"build:dist": "node ../../tools/build-dist.js",
"clean": "bun ../../tools/clean-package.js",
"doc": "typedoc",
"publish": "yarn npm publish --access public"
},
"dependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/adapter-fxhash/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"excludeProtected": true,
"excludePrivate": true,
"excludeInternal": true,
"out": "doc",
"entryPoints": ["src/index.ts"]
}
2 changes: 2 additions & 0 deletions packages/adapter-layer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"build": "node ../../tools/build.js src/index.ts adapter-layer && yarn build:types",
"build:types": "tsc -d --emitDeclarationOnly --noEmit false",
"build:dist": "node ../../tools/build-dist.js",
"clean": "bun ../../tools/clean-package.js",
"doc": "typedoc",
"publish": "yarn npm publish --access public"
},
"dependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/adapter-layer/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"excludeProtected": true,
"excludePrivate": true,
"excludeInternal": true,
"out": "doc",
"entryPoints": ["src/index.ts"]
}
2 changes: 2 additions & 0 deletions packages/adapter-urlparams/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"scripts": {
"build": "node ../../tools/build.js src/index.ts adapter-urlparams",
"build:dist": "node ../../tools/build-dist.js",
"clean": "bun ../../tools/clean-package.js",
"doc": "typedoc",
"publish": "yarn npm publish --access public"
},
"dependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/adapter-urlparams/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"excludeProtected": true,
"excludePrivate": true,
"excludeInternal": true,
"out": "doc",
"entryPoints": ["src/index.ts"]
}
4 changes: 3 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"build": "node ../../tools/build.js src/genart.ts genart && yarn build:types",
"build:types": "tsc -d --emitDeclarationOnly --noEmit false",
"build:dist": "node ../../tools/build-dist.js --decl && cp ../../README.md .",
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/api.ts",
"clean": "bun ../../tools/clean-package.js api params time",
"doc": "typedoc src/api.ts",
"publish": "yarn npm publish --access public",
"test": "bun test"
},
Expand All @@ -27,6 +28,7 @@
},
"files": [
"api",
"params",
"time",
"./*.js",
"./*.d.ts"
Expand Down
7 changes: 7 additions & 0 deletions packages/core/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"excludeProtected": true,
"excludePrivate": true,
"excludeInternal": true,
"out": "doc",
"entryPoints": ["src/index.ts"]
}
1 change: 1 addition & 0 deletions packages/time-fps-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"build:types": "tsc -d --emitDeclarationOnly --noEmit false",
"build:dist": "node ../../tools/build-dist.js",
"clean": "bun ../../tools/clean-package.js",
"doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
"publish": "yarn npm publish --access public"
},
"dependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/time-fps-overlay/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"excludeProtected": true,
"excludePrivate": true,
"excludeInternal": true,
"out": "doc",
"entryPoints": ["src/index.ts"]
}
63 changes: 63 additions & 0 deletions tools/clean-package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { readdirSync, rmSync, statSync, unlinkSync } from "node:fs";
import { basename, sep } from "node:path";

// utility functions adapted from thi.ng/file-io
// used here directly to be entirely self-contained...

const isDirectory = (path) => statSync(path).isDirectory();

const files = (dir, match, maxDepth = Infinity) =>
__files(dir, match, maxDepth, 0);

function* __files(dir, match, maxDepth = Infinity, depth = 0) {
if (depth >= maxDepth) return;
const pred = (x) => match.test(x);
for (let f of readdirSync(dir).sort()) {
const curr = dir + sep + f;
try {
if (isDirectory(curr)) {
yield* __files(curr, match, maxDepth, depth + 1);
} else if (pred(curr)) {
yield curr;
}
} catch (e) {
console.warn(`ignoring file: ${f} (${e.message})`);
}
}
}

function* dirs(dir, pred, maxDepth = Infinity, depth = 0) {
if (depth >= maxDepth) return;
for (let f of readdirSync(dir).sort()) {
const curr = dir + sep + f;
try {
if (statSync(curr).isDirectory()) {
if (pred(curr)) yield curr;
yield* dirs(curr, pred, maxDepth, depth + 1);
}
} catch (e) {
console.warn(`ignoring file/dir: ${f} (${e.message})`);
}
}
}

// accept & merge additional dirs as CLI args
const removeDirs = new Set([
"doc",
"api",
"generated",
"internal",
...process.argv.slice(2),
]);

for (let d of dirs(".", (x) => removeDirs.has(basename(x)), 1)) {
console.log("removing directory:", d);
rmSync(d, { recursive: true, force: true });
}

for (let f of files(".", /\.(map|js|d\.ts|tsbuildinfo|wasn|wast|o)$/)) {
if (f.indexOf("/bin/") === -1) {
console.log("removing file:", f);
unlinkSync(f);
}
}

0 comments on commit 13a05a5

Please sign in to comment.