@temir.ra/create-test115 0.0.28 → 0.0.29
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/README.md +13 -1
- package/buildinfo.txt +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +27 -0
- package/dist/urls.d.ts +5 -0
- package/dist/urls.d.ts.map +1 -0
- package/dist/urls.js +4 -0
- package/package.json +4 -2
- package/template/CLAUDE.md +60 -1
- package/template/README.md +14 -15
- package/template/package.json +3 -1
package/README.md
CHANGED
|
@@ -217,7 +217,9 @@ bun install
|
|
|
217
217
|
|
|
218
218
|
"scripts": {
|
|
219
219
|
|
|
220
|
-
"clean": "rm -rf dist/",
|
|
220
|
+
"clean:dist": "rm -rf dist/",
|
|
221
|
+
"clean:tsbuildinfo": "rm -f tsconfig.build.tsbuildinfo",
|
|
222
|
+
"clean": "bun run clean:dist && bun run clean:tsbuildinfo",
|
|
221
223
|
|
|
222
224
|
// lifecycle hook; runs automatically before "build"; generates buildinfo.txt
|
|
223
225
|
"prebuild": "bun run scripts/buildinfo.ts",
|
|
@@ -302,6 +304,16 @@ AI assistant context files. Provide project layout, commands, and architecture n
|
|
|
302
304
|
## Build
|
|
303
305
|
|
|
304
306
|
```bash
|
|
307
|
+
# remove dist/ and tsconfig.build.tsbuildinfo
|
|
308
|
+
bun run clean
|
|
309
|
+
|
|
310
|
+
# remove dist/ only
|
|
311
|
+
bun run clean:dist
|
|
312
|
+
|
|
313
|
+
# remove tsconfig.build.tsbuildinfo only
|
|
314
|
+
bun run clean:tsbuildinfo
|
|
315
|
+
|
|
316
|
+
# compile + bundle
|
|
305
317
|
bun run build
|
|
306
318
|
```
|
|
307
319
|
|
package/buildinfo.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.29+5b26ba8
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { cpSync, readFileSync, renameSync, writeFileSync } from 'fs';
|
|
3
|
+
import { resolve, basename } from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { buildinfoUrl, changelogUrl, templateUrl } from '#src/urls.js';
|
|
6
|
+
try {
|
|
7
|
+
const dest = process.argv[2];
|
|
8
|
+
if (!dest)
|
|
9
|
+
throw new Error('Destination path is required. Usage: `bun/npm create <template> <destination>`');
|
|
10
|
+
const destinationPath = resolve(process.cwd(), dest);
|
|
11
|
+
const packageName = basename(destinationPath);
|
|
12
|
+
const templatePath = resolve(fileURLToPath(templateUrl));
|
|
13
|
+
cpSync(templatePath, destinationPath, { recursive: true });
|
|
14
|
+
cpSync(resolve(fileURLToPath(changelogUrl)), resolve(destinationPath, 'CHANGELOG-template.md'));
|
|
15
|
+
cpSync(resolve(fileURLToPath(buildinfoUrl)), resolve(destinationPath, 'buildinfo-template.txt'));
|
|
16
|
+
const packageManifestPath = resolve(destinationPath, 'package.json');
|
|
17
|
+
const packageManifest = JSON.parse(readFileSync(packageManifestPath, 'utf-8'));
|
|
18
|
+
packageManifest.name = packageName;
|
|
19
|
+
writeFileSync(packageManifestPath, JSON.stringify(packageManifest, null, 2));
|
|
20
|
+
renameSync(resolve(destinationPath, 'gitignore'), resolve(destinationPath, '.gitignore'));
|
|
21
|
+
console.log(`Template has been successfully instantiated at '${destinationPath}' with package name '${packageName}'.`);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
25
|
+
console.error('Error:', err.message);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
package/dist/urls.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../src/urls.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,EAAE,GAAmC,CAAC;AAC1D,eAAO,MAAM,YAAY,EAAE,GAAyC,CAAC;AACrE,eAAO,MAAM,YAAY,EAAE,GAA0C,CAAC;AACtE,eAAO,MAAM,WAAW,EAAE,GAAqC,CAAC"}
|
package/dist/urls.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temir.ra/create-test115",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"description": "Typescript library template",
|
|
5
5
|
"author": "temir.ra",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
"template"
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
|
-
"clean": "rm -rf dist/",
|
|
30
|
+
"clean:dist": "rm -rf dist/",
|
|
31
|
+
"clean:tsbuildinfo": "rm -f tsconfig.build.tsbuildinfo",
|
|
32
|
+
"clean": "bun run clean:dist && bun run clean:tsbuildinfo",
|
|
31
33
|
"prebuild": "bun run scripts/buildinfo.ts",
|
|
32
34
|
"tests": "bun test",
|
|
33
35
|
"build": "bun run build:lib && bun run build:cli-bundle",
|
package/template/CLAUDE.md
CHANGED
|
@@ -30,9 +30,68 @@ bun run build # Compile + bundle the library
|
|
|
30
30
|
bun run tests # Run unit tests
|
|
31
31
|
bun run typecheck # Type-check without emitting
|
|
32
32
|
bun run dev # Run src/dev.ts in watch mode
|
|
33
|
-
bun run clean
|
|
33
|
+
bun run clean # Remove dist/ and tsconfig.build.tsbuildinfo
|
|
34
|
+
bun run clean:dist # Remove dist/ only
|
|
35
|
+
bun run clean:tsbuildinfo # Remove tsconfig.build.tsbuildinfo only
|
|
34
36
|
```
|
|
35
37
|
|
|
38
|
+
## Writing Code
|
|
39
|
+
|
|
40
|
+
### Where things go
|
|
41
|
+
|
|
42
|
+
| Path | Purpose |
|
|
43
|
+
|------|---------|
|
|
44
|
+
| `src/index.ts` | Public API — the only entry point consumers see; export everything public from here |
|
|
45
|
+
| `src/*.ts` | Library source modules — add new modules here, re-export from `index.ts` |
|
|
46
|
+
| `src/dev.ts` | Development scratchpad — excluded from build, never published; use for manual testing |
|
|
47
|
+
| `tests/*.test.ts` | Unit tests — Bun test runner |
|
|
48
|
+
|
|
49
|
+
### Imports within `src/`
|
|
50
|
+
|
|
51
|
+
`tsconfig.build.json` uses `moduleResolution: nodenext`, so imports between library source files must use explicit `.js` extensions:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { helper } from "./helper.js" // ✓
|
|
55
|
+
import { helper } from "./helper" // ✗ — fails under nodenext
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The `#src/*.js` package alias is available in `dev.ts`, `tests/`, and `scripts/`, but **not** in library source files — tsc emits the specifier verbatim and it would break in published unbundled output.
|
|
59
|
+
|
|
60
|
+
### Explicit return types (`isolatedDeclarations`)
|
|
61
|
+
|
|
62
|
+
All exported declarations require explicit type annotations so tsc can emit `.d.ts` files without cross-file inference:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
export function greet(name: string): string { ... } // ✓
|
|
66
|
+
export function greet(name: string) { ... } // ✗ — implicit return type
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Type-only imports (`verbatimModuleSyntax`)
|
|
70
|
+
|
|
71
|
+
Use `import type` for imports that are only used as types:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import type { Foo } from "./foo.js" // ✓ — type-only import
|
|
75
|
+
import { type Foo, bar } from "./foo.js" // ✓ — mixed
|
|
76
|
+
import { Foo } from "./foo.js" // ✗ — if Foo is only used as a type
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Tests
|
|
80
|
+
|
|
81
|
+
Tests live in `tests/` and use Bun's built-in runner:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { describe, test, expect } from "bun:test"
|
|
85
|
+
|
|
86
|
+
describe("greet", () => {
|
|
87
|
+
test("returns greeting", () => {
|
|
88
|
+
expect(greet("world")).toBe("hello, world")
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Run with `bun run tests`.
|
|
94
|
+
|
|
36
95
|
## TypeScript Configuration
|
|
37
96
|
|
|
38
97
|
Two tsconfig files serve different purposes:
|
package/template/README.md
CHANGED
|
@@ -12,28 +12,27 @@
|
|
|
12
12
|
|
|
13
13
|
# Quick Start
|
|
14
14
|
|
|
15
|
-
**Development**
|
|
16
|
-
|
|
17
15
|
```bash
|
|
18
|
-
#
|
|
19
|
-
bun run
|
|
20
|
-
|
|
21
|
-
# run tests
|
|
22
|
-
bun run tests
|
|
16
|
+
# remove dist/ and tsconfig.build.tsbuildinfo
|
|
17
|
+
bun run clean
|
|
23
18
|
|
|
24
|
-
#
|
|
25
|
-
bun run
|
|
26
|
-
```
|
|
19
|
+
# remove dist/ only
|
|
20
|
+
bun run clean:dist
|
|
27
21
|
|
|
28
|
-
|
|
22
|
+
# remove tsconfig.build.tsbuildinfo only
|
|
23
|
+
bun run clean:tsbuildinfo
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
# compile + bundle
|
|
31
26
|
bun run build
|
|
32
|
-
```
|
|
33
27
|
|
|
34
|
-
|
|
28
|
+
# run tests
|
|
29
|
+
bun run tests
|
|
30
|
+
|
|
31
|
+
# run src/dev.ts in watch mode
|
|
32
|
+
bun run dev
|
|
33
|
+
```
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
**Publish** — see [Publish](#publish).
|
|
37
36
|
|
|
38
37
|
# Documentation
|
|
39
38
|
|
package/template/package.json
CHANGED
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
"buildinfo.txt"
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"clean": "rm -rf dist/",
|
|
33
|
+
"clean:dist": "rm -rf dist/",
|
|
34
|
+
"clean:tsbuildinfo": "rm -f tsconfig.build.tsbuildinfo",
|
|
35
|
+
"clean": "bun run clean:dist && bun run clean:tsbuildinfo",
|
|
34
36
|
"prebuild": "bun run scripts/buildinfo.ts",
|
|
35
37
|
"tests": "bun test",
|
|
36
38
|
"build": "bun run build:lib && bun run build:lib-bundle",
|