@temir.ra/create-template 0.5.5 → 0.6.0
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 +20 -20
- package/README.md +144 -90
- package/dist/CHANGELOG.md +116 -110
- package/dist/buildinfo.txt +1 -1
- package/dist/cli.bundle.js +0 -0
- package/dist/cli.bundle.js.map +1 -1
- package/dist/template/CHANGELOG.md +5 -5
- package/dist/template/README.md +163 -166
- package/dist/template/gitignore +8 -8
- package/dist/template/package.json +51 -46
- package/dist/template/scripts/build-bundle.ts +212 -212
- package/dist/template/scripts/buildinfo.ts +25 -25
- package/dist/template/src/cli.ts +41 -41
- package/dist/template/src/package-urls.ts +8 -8
- package/dist/template/tests/buildinfo.test.ts +26 -26
- package/dist/template/tsconfig.json +33 -33
- package/package.json +7 -2
- package/dist/template/buildinfo.txt +0 -1
package/dist/template/README.md
CHANGED
|
@@ -1,166 +1,163 @@
|
|
|
1
|
-
# Introduction
|
|
2
|
-
|
|
3
|
-
This template scaffolds a ...
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
1. [Quick Start](#quick-start)
|
|
8
|
-
2. [Documentation](#documentation)
|
|
9
|
-
3. [DevOps](#devops)
|
|
10
|
-
1. [Change Management](#change-management)
|
|
11
|
-
2. [Registry](#registry)
|
|
12
|
-
3. [CI/CD Workflows](#cicd-workflows)
|
|
13
|
-
|
|
14
|
-
# Quick Start
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
# placeholder:
|
|
18
|
-
# <TEMPLATE_PACKAGE_NAME: <TEMPLATE_PACKAGE_NAME>
|
|
19
|
-
# <TEMPLATE_NAME: <TEMPLATE_NAME>
|
|
20
|
-
|
|
21
|
-
# print the latest version
|
|
22
|
-
npm info "<TEMPLATE_PACKAGE_NAME>" version
|
|
23
|
-
|
|
24
|
-
# create/update a package from the template in the current directory
|
|
25
|
-
npm create --no-install --no-git "<TEMPLATE_NAME>@latest" .
|
|
26
|
-
|
|
27
|
-
# set metadata in package.json
|
|
28
|
-
|
|
29
|
-
npm update
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
# Documentation
|
|
33
|
-
|
|
34
|
-
The following sections explain the configurations and conventions baked into the generated package. Useful when adapting it to fit specific needs.
|
|
35
|
-
|
|
36
|
-
*<DOCUMENTATION>*
|
|
37
|
-
|
|
38
|
-
# DevOps
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
npm install
|
|
42
|
-
npm update
|
|
43
|
-
|
|
44
|
-
npm run clean
|
|
45
|
-
npm run build
|
|
46
|
-
npm run tests
|
|
47
|
-
|
|
48
|
-
npx tsx dist/cli.bundle.js -- example/
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
git fetch upstream
|
|
53
|
-
git fetch origin
|
|
54
|
-
git fetch . upstream/main:origin/main
|
|
55
|
-
git fetch . origin/main:main
|
|
56
|
-
git push origin main
|
|
57
|
-
git merge --ff-only main
|
|
58
|
-
git push
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Change Management
|
|
62
|
-
|
|
63
|
-
1. Create a new branch for the change.
|
|
64
|
-
2. Make the changes and commit.
|
|
65
|
-
3. Bump the version in [`package.json`](package.json).
|
|
66
|
-
4. Add an entry for the new version in [`CHANGELOG.md`](CHANGELOG.md).
|
|
67
|
-
5. Pull-request the branch.
|
|
68
|
-
6. Ensure package artifacts are current.
|
|
69
|
-
7. Publish.
|
|
70
|
-
|
|
71
|
-
## Registry
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
# placeholder:
|
|
75
|
-
# <SCOPE_WITHOUT_AT: <SCOPE_WITHOUT_AT>
|
|
76
|
-
# <REGISTRY_ORIGIN_AND_PATH: <REGISTRY_ORIGIN_AND_PATH>
|
|
77
|
-
# e.g.
|
|
78
|
-
# registry.npmjs.org/
|
|
79
|
-
# forgejo.example.com/api/packages/<SCOPE_WITHOUT_AT>/npm/
|
|
80
|
-
# <REGISTRY_AUTH_TOKEN_ENV_VAR: <REGISTRY_AUTH_TOKEN_ENV_VAR>
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
`.npmrc`:
|
|
84
|
-
|
|
85
|
-
```ini
|
|
86
|
-
@<SCOPE_WITHOUT_AT>:registry=https://<REGISTRY_ORIGIN_AND_PATH>
|
|
87
|
-
//<REGISTRY_ORIGIN_AND_PATH>:_authToken=${<REGISTRY_AUTH_TOKEN_ENV_VAR>}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
`bunfig.toml`:
|
|
91
|
-
|
|
92
|
-
```toml
|
|
93
|
-
[install.scopes]
|
|
94
|
-
"<SCOPE_WITHOUT_AT>" = { url = "https://<REGISTRY_ORIGIN_AND_PATH>", token = "$<REGISTRY_AUTH_TOKEN_ENV_VAR>" }
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
#
|
|
99
|
-
|
|
100
|
-
# or
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
run: npm
|
|
144
|
-
|
|
145
|
-
- name:
|
|
146
|
-
run: npm run
|
|
147
|
-
|
|
148
|
-
- name:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
npm publish --tag "$NPM_TAG"
|
|
165
|
-
fi
|
|
166
|
-
```
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+
This template scaffolds a ...
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
1. [Quick Start](#quick-start)
|
|
8
|
+
2. [Documentation](#documentation)
|
|
9
|
+
3. [DevOps](#devops)
|
|
10
|
+
1. [Change Management](#change-management)
|
|
11
|
+
2. [Registry](#registry)
|
|
12
|
+
3. [CI/CD Workflows](#cicd-workflows)
|
|
13
|
+
|
|
14
|
+
# Quick Start
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# placeholder:
|
|
18
|
+
# <TEMPLATE_PACKAGE_NAME: <TEMPLATE_PACKAGE_NAME>
|
|
19
|
+
# <TEMPLATE_NAME: <TEMPLATE_NAME>
|
|
20
|
+
|
|
21
|
+
# print the latest version
|
|
22
|
+
npm info "<TEMPLATE_PACKAGE_NAME>" version
|
|
23
|
+
|
|
24
|
+
# create/update a package from the template in the current directory
|
|
25
|
+
npm create --no-install --no-git "<TEMPLATE_NAME>@latest" .
|
|
26
|
+
|
|
27
|
+
# set metadata in package.json
|
|
28
|
+
|
|
29
|
+
npm update
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
# Documentation
|
|
33
|
+
|
|
34
|
+
The following sections explain the configurations and conventions baked into the generated package. Useful when adapting it to fit specific needs.
|
|
35
|
+
|
|
36
|
+
*<DOCUMENTATION>*
|
|
37
|
+
|
|
38
|
+
# DevOps
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install
|
|
42
|
+
npm update
|
|
43
|
+
|
|
44
|
+
npm run clean
|
|
45
|
+
npm run build
|
|
46
|
+
npm run tests
|
|
47
|
+
|
|
48
|
+
npx tsx dist/cli.bundle.js -- example/
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
git fetch upstream
|
|
53
|
+
git fetch origin
|
|
54
|
+
git fetch . upstream/main:origin/main
|
|
55
|
+
git fetch . origin/main:main
|
|
56
|
+
git push origin main
|
|
57
|
+
git merge --ff-only main
|
|
58
|
+
git push
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Change Management
|
|
62
|
+
|
|
63
|
+
1. Create a new branch for the change.
|
|
64
|
+
2. Make the changes and commit.
|
|
65
|
+
3. Bump the version in [`package.json`](package.json).
|
|
66
|
+
4. Add an entry for the new version in [`CHANGELOG.md`](CHANGELOG.md).
|
|
67
|
+
5. Pull-request the branch.
|
|
68
|
+
6. Ensure package artifacts are current.
|
|
69
|
+
7. Publish.
|
|
70
|
+
|
|
71
|
+
## Registry
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# placeholder:
|
|
75
|
+
# <SCOPE_WITHOUT_AT: <SCOPE_WITHOUT_AT>
|
|
76
|
+
# <REGISTRY_ORIGIN_AND_PATH: <REGISTRY_ORIGIN_AND_PATH>
|
|
77
|
+
# e.g.
|
|
78
|
+
# registry.npmjs.org/
|
|
79
|
+
# forgejo.example.com/api/packages/<SCOPE_WITHOUT_AT>/npm/
|
|
80
|
+
# <REGISTRY_AUTH_TOKEN_ENV_VAR: <REGISTRY_AUTH_TOKEN_ENV_VAR>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`.npmrc`:
|
|
84
|
+
|
|
85
|
+
```ini
|
|
86
|
+
@<SCOPE_WITHOUT_AT>:registry=https://<REGISTRY_ORIGIN_AND_PATH>
|
|
87
|
+
//<REGISTRY_ORIGIN_AND_PATH>:_authToken=${<REGISTRY_AUTH_TOKEN_ENV_VAR>}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
or `bunfig.toml`:
|
|
91
|
+
|
|
92
|
+
```toml
|
|
93
|
+
[install.scopes]
|
|
94
|
+
"<SCOPE_WITHOUT_AT>" = { url = "https://<REGISTRY_ORIGIN_AND_PATH>", token = "$<REGISTRY_AUTH_TOKEN_ENV_VAR>" }
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# <REGISTRY_ORIGIN_AND_PATH>
|
|
99
|
+
export <REGISTRY_AUTH_TOKEN_ENV_VAR>=<AUTH_TOKEN>
|
|
100
|
+
# or
|
|
101
|
+
$env:<REGISTRY_AUTH_TOKEN_ENV_VAR> = "<AUTH_TOKEN>"
|
|
102
|
+
npm publish
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## CI/CD Workflows
|
|
106
|
+
|
|
107
|
+
### Build and Publish
|
|
108
|
+
|
|
109
|
+
⚠️ `.npmrc` configuring the package registry and its authentication token is required for the workflow to work.
|
|
110
|
+
|
|
111
|
+
|Parameter|Type|Description|
|
|
112
|
+
|-----|-----|-----|
|
|
113
|
+
|`RUNNER_LABEL`|Variable|The label of the runner to use for the workflow.|
|
|
114
|
+
|`ACCESS_TOKEN`|Secret|The authentication token for the package registry.|
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# placeholder:
|
|
118
|
+
# <REGISTRY_AUTH_TOKEN_ENV_VAR: <REGISTRY_AUTH_TOKEN_ENV_VAR>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
`.github/workflows/build-publish.yml`:
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
name: Build and Publish
|
|
125
|
+
|
|
126
|
+
on:
|
|
127
|
+
push:
|
|
128
|
+
branches:
|
|
129
|
+
- main
|
|
130
|
+
|
|
131
|
+
jobs:
|
|
132
|
+
publish:
|
|
133
|
+
runs-on: ${{ vars.RUNNER_LABEL }}
|
|
134
|
+
steps:
|
|
135
|
+
- uses: actions/checkout@v4
|
|
136
|
+
|
|
137
|
+
- name: Install
|
|
138
|
+
env:
|
|
139
|
+
<REGISTRY_AUTH_TOKEN_ENV_VAR>: ${{ secrets.ACCESS_TOKEN }}
|
|
140
|
+
run: npm ci
|
|
141
|
+
|
|
142
|
+
- name: Build
|
|
143
|
+
run: npm run build
|
|
144
|
+
|
|
145
|
+
- name: Test
|
|
146
|
+
run: npm run tests
|
|
147
|
+
|
|
148
|
+
- name: Publish
|
|
149
|
+
env:
|
|
150
|
+
<REGISTRY_AUTH_TOKEN_ENV_VAR>: ${{ secrets.ACCESS_TOKEN }}
|
|
151
|
+
run: |
|
|
152
|
+
PKG_NAME=$(node -p "require('./package.json').name")
|
|
153
|
+
PKG_VERSION=$(node -p "require('./package.json').version")
|
|
154
|
+
NPM_TAG="latest"
|
|
155
|
+
if echo "$PKG_VERSION" | grep -q -- '-'; then
|
|
156
|
+
NPM_TAG="next"
|
|
157
|
+
fi
|
|
158
|
+
if npm view "$PKG_NAME@$PKG_VERSION" version >/dev/null 2>&1; then
|
|
159
|
+
echo "$PKG_NAME@$PKG_VERSION already published, skipping."
|
|
160
|
+
else
|
|
161
|
+
npm publish --tag "$NPM_TAG"
|
|
162
|
+
fi
|
|
163
|
+
```
|
package/dist/template/gitignore
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
node_modules
|
|
2
|
-
buildinfo.txt
|
|
3
|
-
buildinfo-template.txt
|
|
4
|
-
CHANGELOG-template.md
|
|
5
|
-
README-template.md
|
|
6
|
-
*.tsbuildinfo
|
|
7
|
-
dist/
|
|
8
|
-
example/
|
|
1
|
+
node_modules
|
|
2
|
+
buildinfo.txt
|
|
3
|
+
buildinfo-template.txt
|
|
4
|
+
CHANGELOG-template.md
|
|
5
|
+
README-template.md
|
|
6
|
+
*.tsbuildinfo
|
|
7
|
+
dist/
|
|
8
|
+
example/
|
|
@@ -1,47 +1,52 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"description": "A template for ...",
|
|
5
|
-
"private": false,
|
|
6
|
-
"keywords": [
|
|
7
|
-
"typescript",
|
|
8
|
-
"template"
|
|
9
|
-
],
|
|
10
|
-
"author": "",
|
|
11
|
-
"license": "",
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": ""
|
|
15
|
-
},
|
|
16
|
-
"type": "module",
|
|
17
|
-
"files": [
|
|
18
|
-
"dist/"
|
|
19
|
-
],
|
|
20
|
-
"bin":
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"clean": "
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "A template for ...",
|
|
5
|
+
"private": false,
|
|
6
|
+
"keywords": [
|
|
7
|
+
"typescript",
|
|
8
|
+
"template"
|
|
9
|
+
],
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": ""
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"files": [
|
|
18
|
+
"dist/"
|
|
19
|
+
],
|
|
20
|
+
"bin": {
|
|
21
|
+
"create-template": "dist/cli.bundle.js"
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"entrypoint": "./src/cli.ts"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"imports": {
|
|
29
|
+
"#src/*.js": "./src/*.ts"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"reinstall": "rm -rf node_modules && rm -f package-lock.json bun.lock yarn.lock pnpm-lock.yaml && npm install",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"buildinfo": "tsx scripts/buildinfo.ts",
|
|
35
|
+
"clean:dist": "rm -rf dist/",
|
|
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:bundle",
|
|
41
|
+
"build:bundle": "tsx scripts/build-bundle.ts -- --omit-iife"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "latest",
|
|
45
|
+
"esbuild": "latest",
|
|
46
|
+
"tsx": "latest",
|
|
47
|
+
"typescript": "^6.0.3"
|
|
48
|
+
},
|
|
49
|
+
"allowScripts": {
|
|
50
|
+
"esbuild": true
|
|
51
|
+
}
|
|
47
52
|
}
|