Skip to content

Commit

Permalink
- add a package_json field in deno.json for containing fields rel…
Browse files Browse the repository at this point in the history
…ated to `package.json` when converting project via `dnt` (`build_npm.ts`).

- change package from `@azmi/kitchensink` name to `@oazmi/kitchensink`.
  • Loading branch information
omar-azmi committed Mar 5, 2024
1 parent 4d0059b commit cbaab22
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 18 deletions.
2 changes: 2 additions & 0 deletions build_npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const package_json = await createPackageJson(deno_json_dir, {
}
})
const tsconfig_json = await createTSConfigJson(deno_json_dir)
// we must delete the `exports` property, as it will override the correct version generated by `dntBuild`.
delete package_json["exports"]

await emptyDir(npm_dir)
await dntBuild({
Expand Down
6 changes: 3 additions & 3 deletions build_tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ export const getDenoJson = async (base_dir: string = "./") => {
}

export const createPackageJson = async (deno_json_dir: string = "./", overrides: Partial<PackageJson> = {}): Promise<PackageJson> => {
const { name, version, description, author, license, repository, bugs, exports, devDependencies } = await getDenoJson(deno_json_dir)
const { name, version, description, author, license, repository, bugs, exports, package_json } = await getDenoJson(deno_json_dir)
// note that if you use dnt (deno-to-node), then `exports` will get overwritten
return {
name: name ?? "",
version: version ?? "0.0.0",
description, author, license, repository,
bugs, devDependencies, exports,
description, author, license, repository, bugs, exports,
...package_json,
...overrides
}
}
Expand Down
18 changes: 13 additions & 5 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@azmi/kitchensink",
"name": "@oazmi/kitchensink",
"version": "0.7.5",
"description": "a collection of personal utility functions",
"author": "Omar Azmi",
Expand Down Expand Up @@ -42,7 +42,7 @@
"./.github/",
"./test/",
"./build*.ts",
"clean.ts"
"./clean.ts"
]
},
"test": {
Expand Down Expand Up @@ -70,9 +70,17 @@
"strict": true,
"allowJs": true
},
"devDependencies": {
"typescript": "^5.0.0",
"esbuild": "^0.20.1"
"package_json": {
"dependencies": {},
"devDependencies": {
"typescript": "^5.0.0",
"esbuild": "^0.20.1"
},
"keywords": [
"utility",
"modular",
"typescript"
]
},
"node_packageManager": "npm",
"tasks": {
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ pnpm add -D github:omar-azmi/kitchensink_ts#npm
And now, import whatever the heck you like:
```ts
// import { antigravity } from "python@3.12"
import { setDotPath } from "jsr:@azmi/kitchensink/dotkeypath"
import { pack } from "jsr:@azmi/kitchensink/eightpack"
import { downloadBuffer } from "jsr:@azmi/kitchensink/browser"
import { setDotPath } from "jsr:@oazmi/kitchensink/dotkeypath"
import { pack } from "jsr:@oazmi/kitchensink/eightpack"
import { downloadBuffer } from "jsr:@oazmi/kitchensink/browser"
// or why not use a single import?
// import { setDotPath, pack, downloadBuffer } from "kitchensink"

Expand Down
4 changes: 2 additions & 2 deletions src/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* those are certainly a lot of words thrown in the air with no clarity as to what am I even saying. <br>
* just as they say, a code block example is worth a thousand assembly instructions. here's the gist of it:
* ```ts
* import { bindMethodFactory, bindMethodFactoryByName } from "./kitchensink_ts/binder.ts"
* import { bindMethodFactory, bindMethodFactoryByName } from "@oazmi/kitchensink/binder.ts"
*
* const bind_pushing_to = bindMethodFactory(Array.prototype.push) // equivalent to `bindMethodFactoryByName(Array.prototype, "push")`
* const bind_seek_to = bindMethodFactory(Array.prototype.at, -1) // equivalent to `bindMethodFactoryByName(Array.prototype, "at", -1)`
Expand Down Expand Up @@ -52,7 +52,7 @@
* push3(7, 8, 9) // will work
* pop3() // will work
* // or use this submodule to do the same thing:
* import { bind_array_pop, bind_array_push } from "./kitchensink_ts/binder.ts"
* import { bind_array_pop, bind_array_push } from "@oazmi/kitchensink/binder.ts"
* const push4 = bind_array_push(arr)
* const pop4 = bind_array_pop(arr)
* push4(7, 8, 9) // will work
Expand Down
2 changes: 1 addition & 1 deletion src/builtin_aliases.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** aliases for built-in functions. <br>
* using aliases of nested functions makes your script more minifiable. <br>
* for instance, `Math.min(...nums)` is probably not minifiable by many bundlers,
* however, `import {math_min} from "kitchensink_ts/builtin_aliases.ts"; math_min(...nums)` is minifiable by most bundlers. <br>
* however, `import {math_min} from "@oazmi/kitchensink/builtin_aliases.ts"; math_min(...nums)` is minifiable by most bundlers. <br>
*
* nothing here is re-exported by `./mod.ts`. you will have to import this file directly to use any alias.
* @module
Expand Down
3 changes: 2 additions & 1 deletion src/mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** auto export for all modules, except `devdebug` <br>
* `devdebug` pollutes the `globalThis` object whenever imported. thus, anyone desiring this module should import it using `import {...} from "kitchensink_ts/devdebug"` <br>
* `devdebug` pollutes the `globalThis` object whenever imported.
* thus, anyone desiring this module should import it using `import {...} from "@oazmi/kitchensink/devdebug"` <br>
* also, `builtin_aliases` is not exported either to avoid namespace pollution in IDEs <br>
*/

Expand Down
6 changes: 3 additions & 3 deletions src/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ pnpm add -D github:omar-azmi/kitchensink_ts#npm
And now, import whatever the heck you like:
```ts
// import { antigravity } from "python@3.12"
import { setDotPath } from "jsr:@azmi/kitchensink/dotkeypath"
import { pack } from "jsr:@azmi/kitchensink/eightpack"
import { downloadBuffer } from "jsr:@azmi/kitchensink/browser"
import { setDotPath } from "jsr:@oazmi/kitchensink/dotkeypath"
import { pack } from "jsr:@oazmi/kitchensink/eightpack"
import { downloadBuffer } from "jsr:@oazmi/kitchensink/browser"
// or why not use a single import?
// import { setDotPath, pack, downloadBuffer } from "kitchensink"

Expand Down

0 comments on commit cbaab22

Please sign in to comment.