@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 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.28+db1b08e
1
+ 0.0.29+5b26ba8
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -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,5 @@
1
+ export declare const distUrl: URL;
2
+ export declare const changelogUrl: URL;
3
+ export declare const buildinfoUrl: URL;
4
+ export declare const templateUrl: URL;
5
+ //# sourceMappingURL=urls.d.ts.map
@@ -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
@@ -0,0 +1,4 @@
1
+ export const distUrl = new URL('.', import.meta.url);
2
+ export const changelogUrl = new URL('../CHANGELOG.md', distUrl);
3
+ export const buildinfoUrl = new URL('../buildinfo.txt', distUrl);
4
+ export const templateUrl = new URL('../template', distUrl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temir.ra/create-test115",
3
- "version": "0.0.28",
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",
@@ -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 # Remove dist/
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:
@@ -12,28 +12,27 @@
12
12
 
13
13
  # Quick Start
14
14
 
15
- **Development**
16
-
17
15
  ```bash
18
- # run src/dev.ts in watch mode
19
- bun run dev
20
-
21
- # run tests
22
- bun run tests
16
+ # remove dist/ and tsconfig.build.tsbuildinfo
17
+ bun run clean
23
18
 
24
- # type-check without emitting
25
- bun run typecheck
26
- ```
19
+ # remove dist/ only
20
+ bun run clean:dist
27
21
 
28
- **Build**
22
+ # remove tsconfig.build.tsbuildinfo only
23
+ bun run clean:tsbuildinfo
29
24
 
30
- ```bash
25
+ # compile + bundle
31
26
  bun run build
32
- ```
33
27
 
34
- **Publish**
28
+ # run tests
29
+ bun run tests
30
+
31
+ # run src/dev.ts in watch mode
32
+ bun run dev
33
+ ```
35
34
 
36
- See [Publish](#publish).
35
+ **Publish** — see [Publish](#publish).
37
36
 
38
37
  # Documentation
39
38
 
@@ -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",