@temir.ra/create-template 0.2.1 → 0.4.0-pre.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Version 0
2
2
 
3
+ ## 0.4.0-pre.6
4
+
5
+ 1. Synced template files with `ts-lob@0.11.0-pre.7` template.
6
+ 2. Replaced `bun run` with `npmx tsx` in DevOps commands.
7
+ 3. Cleaned up Quick Start section.
8
+ 4. Updated files from `self`.
9
+
10
+ ## 0.3.0
11
+
12
+ 1. Synced template files with `ts-lib@0.10.0-pre.1` template.
13
+ 2. Added `node:` prefix to imports.
14
+ 3. Updated files from `self`.
15
+
3
16
  ## 0.2.1
4
17
 
5
18
  1. Updated Quick Start section.
package/README.md CHANGED
@@ -14,22 +14,18 @@
14
14
 
15
15
  ```bash
16
16
  # placeholder:
17
- # <NEW_PACKAGE: <NEW_PACKAGE>
18
17
  # <TEMPLATE_PACKAGE_NAME: @temir.ra/create-template
19
18
  # <TEMPLATE_NAME: @temir.ra/template
20
19
 
21
- mkdir -p <NEW_PACKAGE>
22
- cd <NEW_PACKAGE>
23
-
24
20
  # print the latest version
25
- bun info "@temir.ra/create-template" version
21
+ npm info "@temir.ra/create-template" version
26
22
 
27
23
  # create/update a package from the template in the current directory
28
- bun create --no-install --no-git "@temir.ra/template@latest" .
24
+ npm create --no-install --no-git "@temir.ra/template@latest" .
29
25
 
30
26
  # set metadata in package.json
31
27
 
32
- bun install
28
+ npm install
33
29
  ```
34
30
 
35
31
  # Documentation
@@ -41,16 +37,14 @@ The following sections explain the configurations and conventions baked into the
41
37
  # DevOps
42
38
 
43
39
  ```bash
44
- bun update
45
- bun install
46
-
47
- bun run clean
48
- bun run build
49
- bun run tests
40
+ npm update
41
+ npm install
50
42
 
51
- bun run dist/cli.bundle.js -- example/
43
+ npm run clean
44
+ npm run build
45
+ npm run tests
52
46
 
53
- # see publish section for publish instructions
47
+ npmx tsx dist/cli.bundle.js -- example/
54
48
  ```
55
49
 
56
50
  ## Change Management
@@ -59,17 +53,15 @@ bun run dist/cli.bundle.js -- example/
59
53
  2. Make the changes and commit.
60
54
  3. Bump the version in [`package.json`](package.json).
61
55
  4. Add an entry for the new version in [`CHANGELOG.md`](CHANGELOG.md).
62
- 5. Pull request the branch.
56
+ 5. Pull-request the branch.
63
57
  6. Ensure package artifacts are current.
64
58
  7. Publish.
65
59
 
66
60
  ## Publish
67
61
 
68
- Publish to the public npm registry.
69
-
70
- ```powershell
71
- # authenticate
62
+ ```bash
63
+ # registry.npmjs.org/
72
64
  npm login
73
- # publish
74
- bun publish --registry https://registry.npmjs.org/ --access public
65
+
66
+ npm publish --registry https://registry.npmjs.org/
75
67
  ```
package/buildinfo.txt CHANGED
@@ -1 +1 @@
1
- 0.2.1+57fdfbd
1
+ 0.4.0-pre.6+6bec150
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{cpSync as a,readFileSync as g,renameSync as U,writeFileSync as d}from"fs";import{resolve as r}from"path";var n=new URL("../",import.meta.url),i=new URL("buildinfo.txt",n),u=new URL("dist/",n),l=new URL("template/",n),m=new URL("CHANGELOG.md",n),p=new URL("README.md",n);try{let t=process.argv[2];if(!t)throw new Error('First argument must be the package name (e.g. "my-package" or "@my-scope/my-package").');let o=t.replace(/\\/g,"/"),e=r(process.cwd(),o);a(l,e,{recursive:!0}),a(m,r(e,"CHANGELOG-template.md")),a(i,r(e,"buildinfo-template.txt")),a(p,r(e,"README-template.md"));let c=r(e,"package.json"),s=JSON.parse(g(c,"utf-8"));s.name=o,d(c,JSON.stringify(s,null,2)),U(r(e,"gitignore"),r(e,".gitignore")),console.log(`Template has been successfully instantiated at '${e}' with package name '${o}'.`)}catch(t){let o=t instanceof Error?t:new Error(String(t));console.error("Error:",o.message),process.exit(1)}
2
+ import{cpSync as a,readFileSync as g,renameSync as U,writeFileSync as d}from"node:fs";import{resolve as r}from"node:path";var n=new URL("../",import.meta.url),i=new URL("README.md",n),l=new URL("CHANGELOG.md",n),m=new URL("buildinfo.txt",n),u=new URL("dist/",n),p=new URL("template/",n);try{let t=process.argv[2];if(!t)throw new Error('First argument must be the package name (e.g. "my-package" or "@my-scope/my-package").');let o=t.replace(/\\/g,"/"),e=r(process.cwd(),o);a(p,e,{recursive:!0}),a(l,r(e,"CHANGELOG-template.md")),a(m,r(e,"buildinfo-template.txt")),a(i,r(e,"README-template.md"));let c=r(e,"package.json"),s=JSON.parse(g(c,"utf-8"));s.name=o,d(c,JSON.stringify(s,null,2)),U(r(e,"gitignore"),r(e,".gitignore")),console.log(`Template has been successfully instantiated at '${e}' with package name '${o}'.`)}catch(t){let o=t instanceof Error?t:new Error(String(t));console.error("Error:",o.message),process.exit(1)}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/cli.ts", "../src/constants.ts"],
4
- "sourcesContent": ["#!/usr/bin/env node\r\n\r\nimport { cpSync, readFileSync, renameSync, writeFileSync } from 'fs';\r\nimport { resolve } from 'path';\r\nimport {\r\n templateUrl,\r\n changelogUrl,\r\n buildinfoUrl,\r\n readmeUrl\r\n} from './constants.js';\r\n\r\n\r\ntry {\r\n\r\n const packageNameArgument = process.argv[2];\r\n if (!packageNameArgument)\r\n throw new Error('First argument must be the package name (e.g. \"my-package\" or \"@my-scope/my-package\").');\r\n const packageName = packageNameArgument.replace(/\\\\/g, '/');\r\n\r\n const destinationPath = resolve(process.cwd(), packageName);\r\n\r\n cpSync(templateUrl, destinationPath, { recursive: true });\r\n cpSync(changelogUrl, resolve(destinationPath, 'CHANGELOG-template.md'));\r\n cpSync(buildinfoUrl, resolve(destinationPath, 'buildinfo-template.txt'));\r\n cpSync(readmeUrl, resolve(destinationPath, 'README-template.md'));\r\n\r\n const packageJsonPath = resolve(destinationPath, 'package.json');\r\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));\r\n packageJson.name = packageName;\r\n writeFileSync(packageJsonPath, JSON.stringify(packageJson, 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", "export const packageUrl: URL = new URL('../', import.meta.url);\r\nexport const buildinfoUrl: URL = new URL('buildinfo.txt', packageUrl);\r\nexport const distUrl: URL = new URL('dist/', packageUrl);\r\n\r\nexport const templateUrl: URL = new URL('template/', packageUrl);\r\nexport const changelogUrl: URL = new URL('CHANGELOG.md', packageUrl);\r\nexport const readmeUrl: URL = new URL('README.md', packageUrl);\r\n"],
5
- "mappings": ";AAEA,OAAS,UAAAA,EAAQ,gBAAAC,EAAc,cAAAC,EAAY,iBAAAC,MAAqB,KAChE,OAAS,WAAAC,MAAe,OCHjB,IAAMC,EAAkB,IAAI,IAAI,MAAO,YAAY,GAAG,EAChDC,EAAoB,IAAI,IAAI,gBAAiBD,CAAU,EACvDE,EAAe,IAAI,IAAI,QAASF,CAAU,EAE1CG,EAAmB,IAAI,IAAI,YAAaH,CAAU,EAClDI,EAAoB,IAAI,IAAI,eAAgBJ,CAAU,EACtDK,EAAiB,IAAI,IAAI,YAAaL,CAAU,EDM7D,GAAI,CAEA,IAAMM,EAAsB,QAAQ,KAAK,CAAC,EAC1C,GAAI,CAACA,EACD,MAAM,IAAI,MAAM,wFAAwF,EAC5G,IAAMC,EAAcD,EAAoB,QAAQ,MAAO,GAAG,EAEpDE,EAAkBC,EAAQ,QAAQ,IAAI,EAAGF,CAAW,EAE1DG,EAAOC,EAAaH,EAAiB,CAAE,UAAW,EAAK,CAAC,EACxDE,EAAOE,EAAcH,EAAQD,EAAiB,uBAAuB,CAAC,EACtEE,EAAOG,EAAcJ,EAAQD,EAAiB,wBAAwB,CAAC,EACvEE,EAAOI,EAAWL,EAAQD,EAAiB,oBAAoB,CAAC,EAEhE,IAAMO,EAAkBN,EAAQD,EAAiB,cAAc,EACzDQ,EAAc,KAAK,MAAMC,EAAaF,EAAiB,OAAO,CAAC,EACrEC,EAAY,KAAOT,EACnBW,EAAcH,EAAiB,KAAK,UAAUC,EAAa,KAAM,CAAC,CAAC,EAEnEG,EAAWV,EAAQD,EAAiB,WAAW,EAAGC,EAAQD,EAAiB,YAAY,CAAC,EAExF,QAAQ,IAAI,mDAAmDA,CAAe,wBAAwBD,CAAW,IAAI,CAEzH,OACOa,EAAO,CACV,IAAMC,EAAMD,aAAiB,MAAQA,EAAQ,IAAI,MAAM,OAAOA,CAAK,CAAC,EACpE,QAAQ,MAAM,SAAUC,EAAI,OAAO,EACnC,QAAQ,KAAK,CAAC,CAClB",
6
- "names": ["cpSync", "readFileSync", "renameSync", "writeFileSync", "resolve", "packageUrl", "buildinfoUrl", "distUrl", "templateUrl", "changelogUrl", "readmeUrl", "packageNameArgument", "packageName", "destinationPath", "resolve", "cpSync", "templateUrl", "changelogUrl", "buildinfoUrl", "readmeUrl", "packageJsonPath", "packageJson", "readFileSync", "writeFileSync", "renameSync", "error", "err"]
4
+ "sourcesContent": ["#!/usr/bin/env node\r\n\r\nimport { cpSync, readFileSync, renameSync, writeFileSync } from 'node:fs';\r\nimport { resolve } from 'node:path';\r\nimport {\r\n templateUrl,\r\n changelogUrl,\r\n buildinfoUrl,\r\n readmeUrl\r\n} from './constants.js';\r\n\r\n\r\ntry {\r\n\r\n const packageNameArgument = process.argv[2];\r\n if (!packageNameArgument)\r\n throw new Error('First argument must be the package name (e.g. \"my-package\" or \"@my-scope/my-package\").');\r\n const packageName = packageNameArgument.replace(/\\\\/g, '/');\r\n\r\n const destinationPath = resolve(process.cwd(), packageName);\r\n\r\n cpSync(templateUrl, destinationPath, { recursive: true });\r\n cpSync(changelogUrl, resolve(destinationPath, 'CHANGELOG-template.md'));\r\n cpSync(buildinfoUrl, resolve(destinationPath, 'buildinfo-template.txt'));\r\n cpSync(readmeUrl, resolve(destinationPath, 'README-template.md'));\r\n\r\n const packageJsonPath = resolve(destinationPath, 'package.json');\r\n const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));\r\n packageJson.name = packageName;\r\n writeFileSync(packageJsonPath, JSON.stringify(packageJson, 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", "export const packageUrl: URL = new URL('../', import.meta.url);\r\n\r\nexport const readmeUrl: URL = new URL('README.md', packageUrl);\r\nexport const changelogUrl: URL = new URL('CHANGELOG.md', packageUrl);\r\nexport const buildinfoUrl: URL = new URL('buildinfo.txt', packageUrl);\r\nexport const distUrl: URL = new URL('dist/', packageUrl);\r\n\r\nexport const templateUrl: URL = new URL('template/', packageUrl);\r\n"],
5
+ "mappings": ";AAEA,OAAS,UAAAA,EAAQ,gBAAAC,EAAc,cAAAC,EAAY,iBAAAC,MAAqB,UAChE,OAAS,WAAAC,MAAe,YCHjB,IAAMC,EAAkB,IAAI,IAAI,MAAO,YAAY,GAAG,EAEhDC,EAAiB,IAAI,IAAI,YAAaD,CAAU,EAChDE,EAAoB,IAAI,IAAI,eAAgBF,CAAU,EACtDG,EAAoB,IAAI,IAAI,gBAAiBH,CAAU,EACvDI,EAAe,IAAI,IAAI,QAASJ,CAAU,EAE1CK,EAAmB,IAAI,IAAI,YAAaL,CAAU,EDK/D,GAAI,CAEA,IAAMM,EAAsB,QAAQ,KAAK,CAAC,EAC1C,GAAI,CAACA,EACD,MAAM,IAAI,MAAM,wFAAwF,EAC5G,IAAMC,EAAcD,EAAoB,QAAQ,MAAO,GAAG,EAEpDE,EAAkBC,EAAQ,QAAQ,IAAI,EAAGF,CAAW,EAE1DG,EAAOC,EAAaH,EAAiB,CAAE,UAAW,EAAK,CAAC,EACxDE,EAAOE,EAAcH,EAAQD,EAAiB,uBAAuB,CAAC,EACtEE,EAAOG,EAAcJ,EAAQD,EAAiB,wBAAwB,CAAC,EACvEE,EAAOI,EAAWL,EAAQD,EAAiB,oBAAoB,CAAC,EAEhE,IAAMO,EAAkBN,EAAQD,EAAiB,cAAc,EACzDQ,EAAc,KAAK,MAAMC,EAAaF,EAAiB,OAAO,CAAC,EACrEC,EAAY,KAAOT,EACnBW,EAAcH,EAAiB,KAAK,UAAUC,EAAa,KAAM,CAAC,CAAC,EAEnEG,EAAWV,EAAQD,EAAiB,WAAW,EAAGC,EAAQD,EAAiB,YAAY,CAAC,EAExF,QAAQ,IAAI,mDAAmDA,CAAe,wBAAwBD,CAAW,IAAI,CAEzH,OACOa,EAAO,CACV,IAAMC,EAAMD,aAAiB,MAAQA,EAAQ,IAAI,MAAM,OAAOA,CAAK,CAAC,EACpE,QAAQ,MAAM,SAAUC,EAAI,OAAO,EACnC,QAAQ,KAAK,CAAC,CAClB",
6
+ "names": ["cpSync", "readFileSync", "renameSync", "writeFileSync", "resolve", "packageUrl", "readmeUrl", "changelogUrl", "buildinfoUrl", "distUrl", "templateUrl", "packageNameArgument", "packageName", "destinationPath", "resolve", "cpSync", "templateUrl", "changelogUrl", "buildinfoUrl", "readmeUrl", "packageJsonPath", "packageJson", "readFileSync", "writeFileSync", "renameSync", "error", "err"]
7
7
  }
package/package.json CHANGED
@@ -1,23 +1,19 @@
1
1
  {
2
2
  "name": "@temir.ra/create-template",
3
- "version": "0.2.1",
3
+ "version": "0.4.0-pre.6",
4
4
  "description": "A template for a template package.",
5
- "author": "temir.ra",
6
- "license": "MIT",
5
+ "private": false,
7
6
  "keywords": [
8
7
  "typescript",
9
8
  "template-template"
10
9
  ],
10
+ "author": "temir.ra",
11
+ "license": "MIT",
11
12
  "repository": {
12
13
  "type": "git",
13
14
  "url": "https://git.chimps.quest/trs/create-template.git"
14
15
  },
15
- "private": false,
16
16
  "type": "module",
17
- "imports": {
18
- "#src/*.js": "./src/*.ts"
19
- },
20
- "bin": "./dist/cli.bundle.js",
21
17
  "files": [
22
18
  "scripts/buildinfo.ts",
23
19
  "scripts/build-bundle.ts",
@@ -25,24 +21,29 @@
25
21
  "CHANGELOG.md",
26
22
  "buildinfo.txt",
27
23
  "dist/",
24
+ "tests/",
28
25
  "template/"
29
26
  ],
27
+ "bin": "./dist/cli.bundle.js",
28
+ "imports": {
29
+ "#src/*.js": "./src/*.ts"
30
+ },
30
31
  "scripts": {
31
- "reinstall": "rm -rf node_modules && rm -f bun.lock && bun pm cache rm && bun install && bunx tsc --version",
32
+ "reinstall": "shx rm -rf node_modules && shx rm -f package-lock.json bun.lock yarn.lock pnpm-lock.yaml && npm install",
32
33
  "typecheck": "tsc --noEmit",
33
- "buildinfo": "bun run scripts/buildinfo.ts",
34
- "clean:dist": "rm -rf dist/",
35
- "clean:tsbuildinfo": "rm -f *.tsbuildinfo || true",
36
- "clean": "bun run clean:dist && bun run clean:tsbuildinfo",
37
- "tests": "bun test",
38
- "prebuild": "bun run buildinfo",
39
- "build": "bun run build:cli-bundle",
34
+ "buildinfo": "tsx scripts/buildinfo.ts",
35
+ "clean:dist": "shx rm -rf dist/",
36
+ "clean:tsbuildinfo": "shx rm -f tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
37
+ "clean": "npm run clean:dist && npm run clean:tsbuildinfo",
38
+ "tests": "node --import tsx --test tests/**/*.test.ts",
39
+ "prebuild": "npm run buildinfo",
40
+ "build": "npm run build:cli-bundle",
40
41
  "build:cli-bundle": "esbuild src/cli.ts --outdir=dist --entry-names=[dir]/[name].bundle --platform=node --format=esm --bundle --minify --sourcemap=external"
41
42
  },
42
43
  "devDependencies": {
43
- "@types/bun": "latest",
44
44
  "@types/node": "latest",
45
45
  "esbuild": "latest",
46
+ "tsx": "latest",
46
47
  "typescript": "^6.0.3"
47
48
  }
48
49
  }
@@ -1,5 +1,5 @@
1
- import { readFileSync } from 'fs';
2
- import { join } from 'path';
1
+ import { readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
3
  import {
4
4
  build,
5
5
  type BuildFailure,
@@ -1,5 +1,5 @@
1
- import { execSync } from 'child_process';
2
- import { readFileSync, writeFileSync } from 'fs';
1
+ import { execSync } from 'node:child_process';
2
+ import { readFileSync, writeFileSync } from 'node:fs';
3
3
 
4
4
 
5
5
  const BUILD_INFO_FILE = 'buildinfo.txt';
@@ -9,29 +9,23 @@
9
9
  3. [DevOps](#devops)
10
10
  1. [Change Management](#change-management)
11
11
  2. [Publish](#publish)
12
- 1. [npmjs.org](#npmjsorg)
13
- 2. [Custom registry](#custom-registry)
14
12
 
15
13
  # Quick Start
16
14
 
17
15
  ```bash
18
16
  # placeholder:
19
- # <NEW_PACKAGE: <NEW_PACKAGE>
20
17
  # <TEMPLATE_PACKAGE_NAME: <TEMPLATE_PACKAGE_NAME>
21
18
  # <TEMPLATE_NAME: <TEMPLATE_NAME>
22
19
 
23
- mkdir -p <NEW_PACKAGE>
24
- cd <NEW_PACKAGE>
25
-
26
20
  # print the latest version
27
- bun info "<TEMPLATE_PACKAGE_NAME>" version
21
+ npm info "<TEMPLATE_PACKAGE_NAME>" version
28
22
 
29
23
  # create/update a package from the template in the current directory
30
- bun create --no-install --no-git "<TEMPLATE_NAME>@latest" .
24
+ npm create --no-install --no-git "<TEMPLATE_NAME>@latest" .
31
25
 
32
26
  # set metadata in package.json
33
27
 
34
- bun install
28
+ npm install
35
29
  ```
36
30
 
37
31
  # Documentation
@@ -43,16 +37,14 @@ The following sections explain the configurations and conventions baked into the
43
37
  # DevOps
44
38
 
45
39
  ```bash
46
- bun update
47
- bun install
48
-
49
- bun run clean
50
- bun run build
51
- bun run tests
40
+ npm update
41
+ npm install
52
42
 
53
- bun run dist/cli.bundle.js -- example/
43
+ npm run clean
44
+ npm run build
45
+ npm run tests
54
46
 
55
- # see publish section for publish instructions
47
+ npmx tsx dist/cli.bundle.js -- example/
56
48
  ```
57
49
 
58
50
  ## Change Management
@@ -61,51 +53,32 @@ bun run dist/cli.bundle.js -- example/
61
53
  2. Make the changes and commit.
62
54
  3. Bump the version in [`package.json`](package.json).
63
55
  4. Add an entry for the new version in [`CHANGELOG.md`](CHANGELOG.md).
64
- 5. Pull request the branch.
56
+ 5. Pull-request the branch.
65
57
  6. Ensure package artifacts are current.
66
58
  7. Publish.
67
59
 
68
60
  ## Publish
69
61
 
70
- See the following sources to configure the target registry and authentication.
71
-
72
- - [Configuring npm - `npmrc`](https://docs.npmjs.com/cli/v10/configuring-npm/npmrc)
73
- - [Bun package manager - `install.registry`](https://bun.com/docs/runtime/bunfig#install-scopes)
74
-
75
- ⚠️ Package Scope and the authentication for the target registry must be aligned.
76
-
77
- ### `npmjs.org`
78
-
79
- Publish to the public npm registry.
80
-
81
- ```powershell
82
- # authenticate
83
- npm login
84
- # publish
85
- bun publish --registry https://registry.npmjs.org/ --access public
86
- ```
87
-
88
- ### Custom registry
89
-
90
- Publish to a custom registry.
62
+ Configure the scope registry as described in the [`workspace` template README](https://git.chimps.quest/trs/create-workspace#scope-registry).
91
63
 
92
64
  ```bash
93
65
  # placeholder:
94
- # <SCOPE_WITHOUT_AT: <SCOPE_WITHOUT_AT>
95
- # <REGISTRY_URL: <REGISTRY_URL>
96
- # <BUN_PUBLISH_AUTH_TOKEN: <BUN_PUBLISH_AUTH_TOKEN>
66
+ # <REGISTRY_AUTH_TOKEN_ENV_VAR: <REGISTRY_AUTH_TOKEN_ENV_VAR>
67
+ # <REGISTRY_ORIGIN_AND_PATH: <REGISTRY_ORIGIN_AND_PATH>
68
+ # e.g.
69
+ # registry.npmjs.org/
70
+ # forgejo.example.com/api/packages/<SCOPE_WITHOUT_AT>/npm/
97
71
  ```
98
72
 
99
- `~/.bunfig.toml` or `bunfig.toml`:
73
+ Authenticate with the registry:
100
74
 
101
- ```toml
102
- [install.scopes]
103
- "<SCOPE_WITHOUT_AT>" = { url = "<REGISTRY_URL>", token = "$BUN_PUBLISH_AUTH_TOKEN" }
104
- ```
75
+ ```bash
76
+ # registry.npmjs.org/
77
+ npm login
78
+ # or custom registry
79
+ export <REGISTRY_AUTH_TOKEN_ENV_VAR>=<AUTH_TOKEN>
80
+ # or
81
+ $env:<REGISTRY_AUTH_TOKEN_ENV_VAR> = "<AUTH_TOKEN>"
105
82
 
106
- ```powershell
107
- # authenticate
108
- $env:BUN_PUBLISH_AUTH_TOKEN = "<BUN_PUBLISH_AUTH_TOKEN>"
109
- # publish
110
- bun publish
83
+ npm publish --registry https://<REGISTRY_ORIGIN_AND_PATH>
111
84
  ```
@@ -2,22 +2,18 @@
2
2
  "name": "",
3
3
  "version": "0.0.0",
4
4
  "description": "A template for ...",
5
- "author": "",
6
- "license": "",
5
+ "private": false,
7
6
  "keywords": [
8
7
  "typescript",
9
8
  "template"
10
9
  ],
10
+ "author": "",
11
+ "license": "",
11
12
  "repository": {
12
13
  "type": "git",
13
14
  "url": ""
14
15
  },
15
- "private": false,
16
16
  "type": "module",
17
- "imports": {
18
- "#src/*.js": "./src/*.ts"
19
- },
20
- "bin": "./dist/cli.bundle.js",
21
17
  "files": [
22
18
  "scripts/buildinfo.ts",
23
19
  "scripts/build-bundle.ts",
@@ -25,24 +21,29 @@
25
21
  "CHANGELOG.md",
26
22
  "buildinfo.txt",
27
23
  "dist/",
24
+ "tests/",
28
25
  "template/"
29
26
  ],
27
+ "bin": "./dist/cli.bundle.js",
28
+ "imports": {
29
+ "#src/*.js": "./src/*.ts"
30
+ },
30
31
  "scripts": {
31
- "reinstall": "rm -rf node_modules && rm -f bun.lock && bun pm cache rm && bun install && bunx tsc --version",
32
+ "reinstall": "rm -rf node_modules && rm -f package-lock.json bun.lock yarn.lock pnpm-lock.yaml && npm install",
32
33
  "typecheck": "tsc --noEmit",
33
- "buildinfo": "bun run scripts/buildinfo.ts",
34
+ "buildinfo": "tsx scripts/buildinfo.ts",
34
35
  "clean:dist": "rm -rf dist/",
35
- "clean:tsbuildinfo": "rm -f *.tsbuildinfo || true",
36
- "clean": "bun run clean:dist && bun run clean:tsbuildinfo",
37
- "tests": "bun test",
38
- "prebuild": "bun run buildinfo",
39
- "build": "bun run build:cli-bundle",
36
+ "clean:tsbuildinfo": "rm -f tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
37
+ "clean": "npm run clean:dist && npm run clean:tsbuildinfo",
38
+ "tests": "node --import tsx --test tests/**/*.test.ts",
39
+ "prebuild": "npm run buildinfo",
40
+ "build": "npm run build:cli-bundle",
40
41
  "build:cli-bundle": "esbuild src/cli.ts --outdir=dist --entry-names=[dir]/[name].bundle --platform=node --format=esm --bundle --minify --sourcemap=external"
41
42
  },
42
43
  "devDependencies": {
43
- "@types/bun": "latest",
44
44
  "@types/node": "latest",
45
45
  "esbuild": "latest",
46
+ "tsx": "latest",
46
47
  "typescript": "^6.0.3"
47
48
  }
48
49
  }
@@ -1,5 +1,5 @@
1
- import { readFileSync } from 'fs';
2
- import { join } from 'path';
1
+ import { readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
3
  import {
4
4
  build,
5
5
  type BuildFailure,
@@ -1,5 +1,5 @@
1
- import { execSync } from 'child_process';
2
- import { readFileSync, writeFileSync } from 'fs';
1
+ import { execSync } from 'node:child_process';
2
+ import { readFileSync, writeFileSync } from 'node:fs';
3
3
 
4
4
 
5
5
  const BUILD_INFO_FILE = 'buildinfo.txt';
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { cpSync, readFileSync, renameSync, writeFileSync } from 'fs';
4
- import { resolve } from 'path';
3
+ import { cpSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
4
+ import { resolve } from 'node:path';
5
5
  import {
6
6
  templateUrl,
7
7
  changelogUrl,
@@ -1,7 +1,8 @@
1
1
  export const packageUrl: URL = new URL('../', import.meta.url);
2
+
3
+ export const readmeUrl: URL = new URL('README.md', packageUrl);
4
+ export const changelogUrl: URL = new URL('CHANGELOG.md', packageUrl);
2
5
  export const buildinfoUrl: URL = new URL('buildinfo.txt', packageUrl);
3
6
  export const distUrl: URL = new URL('dist/', packageUrl);
4
7
 
5
8
  export const templateUrl: URL = new URL('template/', packageUrl);
6
- export const changelogUrl: URL = new URL('CHANGELOG.md', packageUrl);
7
- export const readmeUrl: URL = new URL('README.md', packageUrl);
@@ -1,24 +1,26 @@
1
- /// <reference types="bun" />
2
- import { describe, it, expect } from 'bun:test';
3
- import { readFileSync } from 'fs';
4
- import { fileURLToPath } from 'url';
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
3
+ import { existsSync, readFileSync } from 'node:fs';
4
+ import { buildinfoUrl, packageUrl } from '#src/constants.js';
5
5
 
6
6
 
7
- const buildinfoUrl = new URL('../buildinfo.txt', import.meta.url);
8
-
9
- // taken from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
7
+ // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
10
8
  // Captures: [1]=major, [2]=minor, [3]=patch, [4]=pre-release, [5]=build-metadata
11
9
  const SEMVER_REGEX =
12
10
  /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
13
11
 
14
- function readBuildinfo(): string {
15
- return readFileSync(fileURLToPath(buildinfoUrl), 'utf-8').trim();
16
- }
17
12
 
18
13
  describe('buildinfo.txt', () => {
19
14
 
20
- it('MUST contain a valid semver string', () => {
21
- expect(readBuildinfo()).toMatch(SEMVER_REGEX);
15
+ it('MUST exist at the specified location', async () => {
16
+ assert.ok(existsSync(buildinfoUrl));
17
+ assert.ok(!existsSync(new URL('wrong.txt', packageUrl)));
18
+ });
19
+
20
+ it('MUST contain a valid semver string', async () => {
21
+ const buildinfo = readFileSync(buildinfoUrl, 'utf-8');
22
+ assert.match(buildinfo, SEMVER_REGEX);
23
+ assert.doesNotMatch('version zwölf', SEMVER_REGEX);
22
24
  });
23
25
 
24
26
  });
@@ -3,8 +3,7 @@
3
3
  "target": "ESNext",
4
4
  "module": "ESNext",
5
5
  "lib": [
6
- "ESNext",
7
- "DOM"
6
+ "ESNext"
8
7
  ],
9
8
  "moduleResolution": "bundler",
10
9
  "strict": true,
@@ -0,0 +1,26 @@
1
+ import { describe, it } from 'node:test';
2
+ import assert from 'node:assert';
3
+ import { existsSync, readFileSync } from 'node:fs';
4
+ import { buildinfoUrl, packageUrl } from '#src/constants.js';
5
+
6
+
7
+ // https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
8
+ // Captures: [1]=major, [2]=minor, [3]=patch, [4]=pre-release, [5]=build-metadata
9
+ const SEMVER_REGEX =
10
+ /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
11
+
12
+
13
+ describe('buildinfo.txt', () => {
14
+
15
+ it('MUST exist at the specified location', async () => {
16
+ assert.ok(existsSync(buildinfoUrl));
17
+ assert.ok(!existsSync(new URL('wrong.txt', packageUrl)));
18
+ });
19
+
20
+ it('MUST contain a valid semver string', async () => {
21
+ const buildinfo = readFileSync(buildinfoUrl, 'utf-8');
22
+ assert.match(buildinfo, SEMVER_REGEX);
23
+ assert.doesNotMatch('version zwölf', SEMVER_REGEX);
24
+ });
25
+
26
+ });