bonacci 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +24 -0
- package/README.md +60 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +20 -0
- package/dist/fibonacci.d.ts +9 -0
- package/dist/fibonacci.js +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +65 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
|
2
|
+
|
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
+
distribute this software, either in source code form or as a compiled
|
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
+
means.
|
|
7
|
+
|
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
+
of this software dedicate any and all copyright interest in the
|
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
|
11
|
+
of the public at large and to the detriment of our heirs and
|
|
12
|
+
successors. We intend this dedication to be an overt act of
|
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
+
software under copyright law.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
24
|
+
For more information, please refer to <http://unlicense.org/>
|
package/README.md
CHANGED
|
@@ -1,3 +1,61 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Node.js Starter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A minimal template for building a [Node.js](https://nodejs.org/en) library in [TypeScript](https://www.typescriptlang.org/) with [ESM](https://nodejs.org/api/esm.html) support and an optional CLI. Ships pre-configured with formatting, linting, 100% test coverage enforcement, pre-commit hooks, and CI.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
Create a new repository from this template on GitHub using [this link](https://github.com/new?template_name=nodejs-starter&template_owner=threeal), or clone it locally and point it at your own remote.
|
|
8
|
+
|
|
9
|
+
## Setup
|
|
10
|
+
|
|
11
|
+
Install [pnpm](https://pnpm.io/), then install dependencies:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pnpm install
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Install [Lefthook](https://lefthook.dev/), then register the pre-commit hook:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
lefthook install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Customizing
|
|
24
|
+
|
|
25
|
+
Replace or extend the template files to fit your project:
|
|
26
|
+
|
|
27
|
+
- **`src/`** — Replace the placeholder library, CLI, and tests with your own code.
|
|
28
|
+
- **`CLAUDE.md`** — Replace with guidance specific to your project.
|
|
29
|
+
- **`LICENSE`** — Replace with your preferred license, or keep the [Unlicense](https://unlicense.org/).
|
|
30
|
+
- **`package.json`** — Update the package name, description, author, and other metadata.
|
|
31
|
+
- **`README.md`** — Replace with a description of your project.
|
|
32
|
+
|
|
33
|
+
If your project doesn't need a CLI, remove `src/cli.ts`, the `bin` entry in `package.json`, and the `yargs` and `@types/yargs` dependencies.
|
|
34
|
+
|
|
35
|
+
## Development
|
|
36
|
+
|
|
37
|
+
Run the tests with coverage through Vitest:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pnpm vitest run
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The project enforces 100% code coverage, counting only files the tests import.
|
|
44
|
+
|
|
45
|
+
Each `git commit` runs the pre-commit hook registered during setup, which checks your changes and fixes what it can in place. If it fails, fix any reported issues, re-stage the changed files, and commit again.
|
|
46
|
+
|
|
47
|
+
After committing, push to `main` or open a pull request from another branch — CI will run the same checks across all files, plus additional checks of its own.
|
|
48
|
+
|
|
49
|
+
## Releasing
|
|
50
|
+
|
|
51
|
+
Push a version tag to create a draft release with notes generated by GitHub and the packed tarball attached. Review the draft on GitHub, edit the notes if needed, and publish it when it's ready.
|
|
52
|
+
|
|
53
|
+
To also publish to the [npm registry](https://www.npmjs.com/), add an [npm access token](https://docs.npmjs.com/creating-and-viewing-access-tokens) with publish rights as the `NPM_TOKEN` repository secret. Publishing the draft then publishes the same tarball to npm. If your project isn't published to npm, remove `.github/workflows/publish.yaml`.
|
|
54
|
+
|
|
55
|
+
## Framework-Specific Templates
|
|
56
|
+
|
|
57
|
+
For a more opinionated starting point in a specific framework:
|
|
58
|
+
|
|
59
|
+
- **[Action Starter](https://github.com/threeal/action-starter)** — JavaScript GitHub Action projects.
|
|
60
|
+
- **[Discord Bot Starter](https://github.com/threeal/discord-bot-starter)** — Discord bot projects.
|
|
61
|
+
- **[React Starter](https://github.com/threeal/react-starter)** — React app projects.
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import yargs from "yargs";
|
|
4
|
+
import { hideBin } from "yargs/helpers";
|
|
5
|
+
import { fibonacciSequence } from "./fibonacci.js";
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const { version } = require("../package.json");
|
|
8
|
+
await yargs(hideBin(process.argv))
|
|
9
|
+
.scriptName("bonacci")
|
|
10
|
+
.version(version)
|
|
11
|
+
.command("$0 <n>", "Generate a Fibonacci sequence up to the given number of terms", (y) => y.positional("n", {
|
|
12
|
+
type: "number",
|
|
13
|
+
demandOption: true,
|
|
14
|
+
describe: "The number of terms",
|
|
15
|
+
}), (argv) => {
|
|
16
|
+
const sequence = fibonacciSequence(argv.n);
|
|
17
|
+
process.stdout.write(`${sequence.join(" ")}\n`);
|
|
18
|
+
})
|
|
19
|
+
.strict()
|
|
20
|
+
.parse();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a Fibonacci sequence up to the given number of terms.
|
|
3
|
+
*
|
|
4
|
+
* The sequence starts from `1, 1`, and exactly `n` terms are returned, so an
|
|
5
|
+
* `n` of 0 yields an empty sequence.
|
|
6
|
+
* @param n - The number of terms.
|
|
7
|
+
* @returns A Fibonacci sequence.
|
|
8
|
+
*/
|
|
9
|
+
export declare function fibonacciSequence(n: number): number[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a Fibonacci sequence up to the given number of terms.
|
|
3
|
+
*
|
|
4
|
+
* The sequence starts from `1, 1`, and exactly `n` terms are returned, so an
|
|
5
|
+
* `n` of 0 yields an empty sequence.
|
|
6
|
+
* @param n - The number of terms.
|
|
7
|
+
* @returns A Fibonacci sequence.
|
|
8
|
+
*/
|
|
9
|
+
export function fibonacciSequence(n) {
|
|
10
|
+
const sequence = new Array(n).fill(1);
|
|
11
|
+
for (let i = 2; i < n; ++i) {
|
|
12
|
+
sequence[i] = sequence[i - 2] + sequence[i - 1];
|
|
13
|
+
}
|
|
14
|
+
return sequence;
|
|
15
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { fibonacciSequence } from "./fibonacci.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { fibonacciSequence } from "./fibonacci.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bonacci",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "An example library and CLI for generating a Fibonacci sequence",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"fibonacci",
|
|
7
|
+
"math"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/leonardo/bonacci#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/leonardo/bonacci/issues",
|
|
12
|
+
"email": "leonardo@bonacci.com"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "github:leonardo/bonacci"
|
|
17
|
+
},
|
|
18
|
+
"license": "Unlicense",
|
|
19
|
+
"author": "Leonardo Bonacci <leonardo@bonacci.com>",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
|
+
"import": "dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"bin": {
|
|
28
|
+
"bonacci": "dist/cli.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"yargs": "^18.2.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@eslint/js": "^10.0.1",
|
|
38
|
+
"@tsconfig/node26": "^26.0.2",
|
|
39
|
+
"@types/node": "^26.6.6",
|
|
40
|
+
"@types/yargs": "^17.0.35",
|
|
41
|
+
"@vitest/coverage-v8": "^5.1.1",
|
|
42
|
+
"eslint": "^10.15.0",
|
|
43
|
+
"eslint-plugin-jsdoc": "^65.5.4",
|
|
44
|
+
"jiti": "^2.7.0",
|
|
45
|
+
"prettier": "^3.10.1",
|
|
46
|
+
"prettier-plugin-organize-imports": "^4.3.0",
|
|
47
|
+
"typescript": "^6.0.3",
|
|
48
|
+
"typescript-eslint": "^8.73.0",
|
|
49
|
+
"vite": "^8.3.8",
|
|
50
|
+
"vitest": "^5.1.1"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=26"
|
|
54
|
+
},
|
|
55
|
+
"devEngines": {
|
|
56
|
+
"packageManager": {
|
|
57
|
+
"name": "pnpm",
|
|
58
|
+
"version": "^12.23.0",
|
|
59
|
+
"onFail": "download"
|
|
60
|
+
},
|
|
61
|
+
"runtime": {
|
|
62
|
+
"name": "node",
|
|
63
|
+
"version": "^26.13.1",
|
|
64
|
+
"onFail": "download"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"scripts": {}
|
|
6
68
|
}
|