@temir.ra/create-test115 0.0.27 → 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 +20 -8
- package/buildinfo.txt +1 -1
- package/dist/cli.bundle.js.map +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 +7 -16
- package/template/CLAUDE.md +62 -3
- package/template/README.md +15 -13
- package/template/package.json +5 -5
- package/template/scripts/build-lib-bundle.ts +1 -1
- package/template/src/dev.ts +10 -0
package/README.md
CHANGED
|
@@ -197,10 +197,12 @@ bun install
|
|
|
197
197
|
}
|
|
198
198
|
},
|
|
199
199
|
|
|
200
|
-
// package-internal import
|
|
201
|
-
// use
|
|
200
|
+
// package-internal import alias resolved natively by Node.js and Bun at runtime; key must start with #
|
|
201
|
+
// for use in dev.ts, tests/, and scripts/ only — NOT in library source files compiled by tsconfig.build.json
|
|
202
|
+
// the .js extension is required in import statements (nodenext compliance);
|
|
203
|
+
// the runtime maps it to the actual .ts source file via this field
|
|
202
204
|
"imports": {
|
|
203
|
-
"#src
|
|
205
|
+
"#src/*.js": "./src/*.ts"
|
|
204
206
|
},
|
|
205
207
|
|
|
206
208
|
// CLI entry point; omit if the package is not a CLI tool
|
|
@@ -215,12 +217,14 @@ bun install
|
|
|
215
217
|
|
|
216
218
|
"scripts": {
|
|
217
219
|
|
|
218
|
-
"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",
|
|
219
223
|
|
|
220
224
|
// lifecycle hook; runs automatically before "build"; generates buildinfo.txt
|
|
221
225
|
"prebuild": "bun run scripts/buildinfo.ts",
|
|
222
226
|
|
|
223
|
-
"
|
|
227
|
+
"tests": "bun test",
|
|
224
228
|
|
|
225
229
|
"build": "bun run build:lib && bun run build:lib-bundle",
|
|
226
230
|
|
|
@@ -299,10 +303,18 @@ AI assistant context files. Provide project layout, commands, and architecture n
|
|
|
299
303
|
|
|
300
304
|
## Build
|
|
301
305
|
|
|
302
|
-
`prebuild` runs automatically before `build`, generating `buildinfo.txt`.
|
|
303
|
-
|
|
304
306
|
```bash
|
|
305
|
-
|
|
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
|
|
317
|
+
bun run build
|
|
306
318
|
```
|
|
307
319
|
|
|
308
320
|
## Change Management
|
package/buildinfo.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.29+5b26ba8
|
package/dist/cli.bundle.js.map
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["..\\src\\cli.ts", "..\\src\\urls.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"#!/usr/bin/env node\r\n\r\nimport { cpSync, readFileSync, renameSync, writeFileSync } from 'fs';\r\nimport { resolve, basename } from 'path';\r\nimport { fileURLToPath } from 'url';\r\nimport { buildinfoUrl, changelogUrl, templateUrl } from '
|
|
5
|
+
"#!/usr/bin/env node\r\n\r\nimport { cpSync, readFileSync, renameSync, writeFileSync } from 'fs';\r\nimport { resolve, basename } from 'path';\r\nimport { fileURLToPath } from 'url';\r\nimport { buildinfoUrl, changelogUrl, templateUrl } from '#src/urls.js';\r\n\r\n\r\ntry {\r\n\r\n const dest = process.argv[2];\r\n if (!dest) throw new Error('Destination path is required. Usage: `bun/npm create <template> <destination>`');\r\n\r\n const destinationPath = resolve(process.cwd(), dest);\r\n const packageName = basename(destinationPath);\r\n\r\n const templatePath = resolve(fileURLToPath(templateUrl));\r\n\r\n cpSync(templatePath, destinationPath, { recursive: true });\r\n cpSync(resolve(fileURLToPath(changelogUrl)), resolve(destinationPath, 'CHANGELOG-template.md'));\r\n cpSync(resolve(fileURLToPath(buildinfoUrl)), resolve(destinationPath, 'buildinfo-template.txt'));\r\n\r\n const packageManifestPath = resolve(destinationPath, 'package.json');\r\n const packageManifest = JSON.parse(readFileSync(packageManifestPath, 'utf-8'));\r\n packageManifest.name = packageName;\r\n writeFileSync(packageManifestPath, JSON.stringify(packageManifest, null, 2));\r\n\r\n renameSync(resolve(destinationPath, 'gitignore'), resolve(destinationPath, '.gitignore'));\r\n\r\n console.log(`Template has been successfully instantiated at '${destinationPath}' with package name '${packageName}'.`);\r\n\r\n}\r\ncatch (error) {\r\n const err = error instanceof Error ? error : new Error(String(error));\r\n console.error('Error:', err.message);\r\n process.exit(1);\r\n}\r\n",
|
|
6
6
|
"export const distUrl: URL = new URL('.', import.meta.url);\r\nexport const changelogUrl: URL = new URL('../CHANGELOG.md', distUrl);\r\nexport const buildinfoUrl: URL = new URL('../buildinfo.txt', distUrl);\r\nexport const templateUrl: URL = new URL('../template', distUrl);\r\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";AAEA,iBAAS,kBAAQ,gBAAc,mBAAY,WAC3C,kBAAS,cAAS,aAClB,wBAAS,YCJF,IAAM,EAAe,IAAI,IAAI,IAAK,YAAY,GAAG,EAC3C,EAAoB,IAAI,IAAI,kBAAmB,CAAO,EACtD,EAAoB,IAAI,IAAI,mBAAoB,CAAO,EACvD,EAAmB,IAAI,IAAI,cAAe,CAAO,EDK9D,GAAI,CAEA,IAAM,EAAO,QAAQ,KAAK,GAC1B,GAAI,CAAC,EAAM,MAAU,MAAM,gFAAgF,EAE3G,IAAM,EAAkB,EAAQ,QAAQ,IAAI,EAAG,CAAI,EAC7C,EAAc,EAAS,CAAe,EAEtC,EAAe,EAAQ,EAAc,CAAW,CAAC,EAEvD,EAAO,EAAc,EAAiB,CAAE,UAAW,EAAK,CAAC,EACzD,EAAO,EAAQ,EAAc,CAAY,CAAC,EAAG,EAAQ,EAAiB,uBAAuB,CAAC,EAC9F,EAAO,EAAQ,EAAc,CAAY,CAAC,EAAG,EAAQ,EAAiB,wBAAwB,CAAC,EAE/F,IAAM,EAAsB,EAAQ,EAAiB,cAAc,EAC7D,EAAkB,KAAK,MAAM,EAAa,EAAqB,OAAO,CAAC,EAC7E,EAAgB,KAAO,EACvB,EAAc,EAAqB,KAAK,UAAU,EAAiB,KAAM,CAAC,CAAC,EAE3E,EAAW,EAAQ,EAAiB,WAAW,EAAG,EAAQ,EAAiB,YAAY,CAAC,EAExF,QAAQ,IAAI,mDAAmD,yBAAuC,KAAe,EAGzH,MAAO,EAAO,CACV,IAAM,EAAM,aAAiB,MAAQ,EAAY,MAAM,OAAO,CAAK,CAAC,EACpE,QAAQ,MAAM,SAAU,EAAI,OAAO,EACnC,QAAQ,KAAK,CAAC",
|
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",
|
|
@@ -16,18 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
18
|
"sideEffects": false,
|
|
19
|
-
"exports": {
|
|
20
|
-
".": {
|
|
21
|
-
"entrypoint": "./src/cli.ts",
|
|
22
|
-
"browser": "./dist/index.bundle.js",
|
|
23
|
-
"import": "./dist/index.js",
|
|
24
|
-
"types": "./dist/index.d.ts"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
19
|
"imports": {
|
|
28
|
-
"#src
|
|
29
|
-
"#scripts/*": "./scripts/*",
|
|
30
|
-
"#tests/*": "./tests/*"
|
|
20
|
+
"#src/*.js": "./src/*.ts"
|
|
31
21
|
},
|
|
32
22
|
"bin": "./dist/cli.bundle.js",
|
|
33
23
|
"files": [
|
|
@@ -37,12 +27,13 @@
|
|
|
37
27
|
"template"
|
|
38
28
|
],
|
|
39
29
|
"scripts": {
|
|
40
|
-
"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",
|
|
41
33
|
"prebuild": "bun run scripts/buildinfo.ts",
|
|
42
|
-
"
|
|
43
|
-
"build": "bun run build:lib && bun run build:
|
|
34
|
+
"tests": "bun test",
|
|
35
|
+
"build": "bun run build:lib && bun run build:cli-bundle",
|
|
44
36
|
"build:lib": "tsc --project tsconfig.build.json",
|
|
45
|
-
"build:lib-bundle": "bun run scripts/build-lib-bundle.ts",
|
|
46
37
|
"build:cli-bundle": "bun build src/cli.ts --entry-naming \"[dir]/[name].bundle.[ext]\" --outdir dist --target node --format esm --minify --sourcemap=external",
|
|
47
38
|
"typecheck": "tsc --noEmit",
|
|
48
39
|
"dev": "bun run --watch src/dev.ts"
|
package/template/CLAUDE.md
CHANGED
|
@@ -27,12 +27,71 @@ A Bun TypeScript library.
|
|
|
27
27
|
```bash
|
|
28
28
|
bun install # Install dependencies
|
|
29
29
|
bun run build # Compile + bundle the library
|
|
30
|
-
bun run
|
|
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:
|
|
@@ -66,7 +125,7 @@ The `exports` field in `package.json` maps consumers to the right file:
|
|
|
66
125
|
Key `package.json` fields:
|
|
67
126
|
|
|
68
127
|
- `"sideEffects": false` — enables full tree-shaking by bundlers
|
|
69
|
-
- `"imports": { "#src
|
|
128
|
+
- `"imports": { "#src/*.js": "./src/*.ts" }` — package-internal alias for `src/`; use as `import { foo } from "#src/module.js"`. **Only for `dev.ts`, `tests/`, and `scripts/`** — not for library source files compiled by `tsconfig.build.json`, as tsc emits the specifier verbatim and it would break in published unbundled output.
|
|
70
129
|
|
|
71
130
|
## Publishing
|
|
72
131
|
|
package/template/README.md
CHANGED
|
@@ -12,25 +12,27 @@
|
|
|
12
12
|
|
|
13
13
|
# Quick Start
|
|
14
14
|
|
|
15
|
-
**Development**
|
|
16
|
-
|
|
17
15
|
```bash
|
|
18
|
-
|
|
19
|
-
bun
|
|
20
|
-
bun run typecheck # type-check without emitting
|
|
21
|
-
```
|
|
16
|
+
# remove dist/ and tsconfig.build.tsbuildinfo
|
|
17
|
+
bun run clean
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
# remove dist/ only
|
|
20
|
+
bun run clean:dist
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
# remove tsconfig.build.tsbuildinfo only
|
|
23
|
+
bun run clean:tsbuildinfo
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
bun run build
|
|
29
|
-
|
|
25
|
+
# compile + bundle
|
|
26
|
+
bun run build
|
|
27
|
+
|
|
28
|
+
# run tests
|
|
29
|
+
bun run tests
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
# run src/dev.ts in watch mode
|
|
32
|
+
bun run dev
|
|
33
|
+
```
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
**Publish** — see [Publish](#publish).
|
|
34
36
|
|
|
35
37
|
# Documentation
|
|
36
38
|
|
package/template/package.json
CHANGED
|
@@ -22,9 +22,7 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"imports": {
|
|
25
|
-
"#src
|
|
26
|
-
"#scripts/*": "./scripts/*",
|
|
27
|
-
"#tests/*": "./tests/*"
|
|
25
|
+
"#src/*.js": "./src/*.ts"
|
|
28
26
|
},
|
|
29
27
|
"files": [
|
|
30
28
|
"dist",
|
|
@@ -32,9 +30,11 @@
|
|
|
32
30
|
"buildinfo.txt"
|
|
33
31
|
],
|
|
34
32
|
"scripts": {
|
|
35
|
-
"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",
|
|
36
36
|
"prebuild": "bun run scripts/buildinfo.ts",
|
|
37
|
-
"
|
|
37
|
+
"tests": "bun test",
|
|
38
38
|
"build": "bun run build:lib && bun run build:lib-bundle",
|
|
39
39
|
"build:lib": "tsc --project tsconfig.build.json",
|
|
40
40
|
"build:lib-bundle": "bun run scripts/build-lib-bundle.ts",
|
package/template/src/dev.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import { buildinfoUrl, changelogUrl, distUrl } from '#src/urls.js';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
|
|
4
|
+
|
|
1
5
|
const start: number = performance.now();
|
|
2
6
|
|
|
7
|
+
console.log(`'distPath':`, fileURLToPath(distUrl));
|
|
8
|
+
console.log(`'buildinfoPath':`, fileURLToPath(buildinfoUrl));
|
|
9
|
+
console.log(`'changelogPath':`, fileURLToPath(changelogUrl));
|
|
10
|
+
|
|
11
|
+
|
|
3
12
|
// dev code
|
|
4
13
|
|
|
14
|
+
|
|
5
15
|
console.log(`${(performance.now() - start).toFixed(3)}ms`);
|