@bryanchu10/create-template-ts 1.1.1 → 1.2.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/dist/index.js +37 -16
- package/package.json +5 -2
- package/templates/ts-library/.github/workflows/publish.yml +29 -0
- package/templates/ts-library/.release-it.js +26 -0
- package/templates/ts-library/_gitignore +4 -0
- package/templates/ts-library/_vscode/settings.json +36 -0
- package/templates/ts-library/eslint.config.js +42 -0
- package/templates/ts-library/package.json +23 -0
- package/templates/ts-library/pnpm-lock.yaml +5427 -0
- package/templates/ts-library/pnpm-workspace.yaml +4 -0
- package/templates/ts-library/src/index.test.ts +20 -0
- package/templates/ts-library/src/index.ts +19 -0
- package/templates/ts-library/tsconfig.json +10 -0
- package/templates/ts-library/tsdown.config.ts +8 -0
- package/templates/ts-script/_gitignore +3 -1
- package/templates/ts-script/eslint.config.js +1 -0
- package/templates/ts-script/tsconfig.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1461,19 +1461,34 @@ var require_index_cjs = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
1461
1461
|
const DEFAULT_PROJECT_NAME = "ts-start";
|
|
1462
1462
|
//#endregion
|
|
1463
1463
|
//#region src/constants/templates.ts
|
|
1464
|
-
const TEMPLATES =
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
}
|
|
1464
|
+
const TEMPLATES = {
|
|
1465
|
+
"ts-script": {
|
|
1466
|
+
hint: "TypeScript script/tooling",
|
|
1467
|
+
withPeerDependencies: false,
|
|
1468
|
+
deps: ["ts-pattern", "neverthrow"],
|
|
1469
|
+
devDeps: [
|
|
1470
|
+
"eslint",
|
|
1471
|
+
"@antfu/eslint-config",
|
|
1472
|
+
"tsx",
|
|
1473
|
+
"typescript",
|
|
1474
|
+
"rolldown"
|
|
1475
|
+
]
|
|
1476
|
+
},
|
|
1477
|
+
"ts-library": {
|
|
1478
|
+
hint: "TypeScript library with tests and release tooling",
|
|
1479
|
+
withPeerDependencies: true,
|
|
1480
|
+
deps: ["ts-pattern", "neverthrow"],
|
|
1481
|
+
devDeps: [
|
|
1482
|
+
"eslint",
|
|
1483
|
+
"@antfu/eslint-config",
|
|
1484
|
+
"typescript",
|
|
1485
|
+
"tsdown",
|
|
1486
|
+
"vitest",
|
|
1487
|
+
"release-it",
|
|
1488
|
+
"@release-it/conventional-changelog"
|
|
1489
|
+
]
|
|
1490
|
+
}
|
|
1491
|
+
};
|
|
1477
1492
|
//#endregion
|
|
1478
1493
|
//#region src/utils/get-latest-ver.ts
|
|
1479
1494
|
var import_index_cjs = require_index_cjs();
|
|
@@ -1903,7 +1918,11 @@ function validateProjectName(value) {
|
|
|
1903
1918
|
function getTemplate() {
|
|
1904
1919
|
return (0, import_index_cjs.fromPromise)(xe({
|
|
1905
1920
|
message: "Select a template",
|
|
1906
|
-
options:
|
|
1921
|
+
options: Object.keys(TEMPLATES).map((key) => ({
|
|
1922
|
+
value: key,
|
|
1923
|
+
label: key,
|
|
1924
|
+
hint: TEMPLATES[key].hint
|
|
1925
|
+
}))
|
|
1907
1926
|
}), (e) => e).andThen((answer) => M(answer).with(z.when(q$1), () => (0, import_index_cjs.err)(/* @__PURE__ */ new Error("Operation cancelled"))).with(z.string, (t) => (0, import_index_cjs.ok)(t)).exhaustive());
|
|
1908
1927
|
}
|
|
1909
1928
|
//#endregion
|
|
@@ -1924,7 +1943,7 @@ function resolveNewDir(projectName) {
|
|
|
1924
1943
|
template,
|
|
1925
1944
|
targetDir
|
|
1926
1945
|
}))).andThen(({ projectName, template, targetDir }) => {
|
|
1927
|
-
const { deps, devDeps } = TEMPLATES
|
|
1946
|
+
const { withPeerDependencies, deps, devDeps } = TEMPLATES[template];
|
|
1928
1947
|
const s = ft();
|
|
1929
1948
|
s.start("Fetching latest package versions");
|
|
1930
1949
|
return import_index_cjs.ResultAsync.combine([import_index_cjs.ResultAsync.combine([...deps].map((dep) => getLatestVer(dep))), import_index_cjs.ResultAsync.combine([...devDeps].map((dep) => getLatestVer(dep)))]).map(([depVers, devDepVers]) => {
|
|
@@ -1933,6 +1952,7 @@ function resolveNewDir(projectName) {
|
|
|
1933
1952
|
projectName,
|
|
1934
1953
|
template,
|
|
1935
1954
|
targetDir,
|
|
1955
|
+
withPeerDependencies,
|
|
1936
1956
|
deps,
|
|
1937
1957
|
devDeps,
|
|
1938
1958
|
depVers,
|
|
@@ -1942,7 +1962,7 @@ function resolveNewDir(projectName) {
|
|
|
1942
1962
|
s.stop("Failed to fetch package versions");
|
|
1943
1963
|
return error;
|
|
1944
1964
|
});
|
|
1945
|
-
}).andThen(({ projectName, template, targetDir, deps, devDeps, depVers, devDepVers }) => {
|
|
1965
|
+
}).andThen(({ projectName, template, targetDir, withPeerDependencies, deps, devDeps, depVers, devDepVers }) => {
|
|
1946
1966
|
const depsMap = Object.fromEntries(deps.map((dep, i) => [dep, depVers[i]]));
|
|
1947
1967
|
const devDepsMap = {
|
|
1948
1968
|
...Object.fromEntries(devDeps.map((dep, i) => [dep, devDepVers[i]])),
|
|
@@ -1961,6 +1981,7 @@ function resolveNewDir(projectName) {
|
|
|
1961
1981
|
}).andThen(() => safeReadFileSync(pkgPath)).andThen((content) => safeJsonParse(content)).andThen((pkg) => {
|
|
1962
1982
|
pkg.name = basename(projectName);
|
|
1963
1983
|
pkg.dependencies = depsMap;
|
|
1984
|
+
Object.assign(pkg, withPeerDependencies ? { peerDependencies: Object.fromEntries(Object.entries(depsMap).map(([dep, ver]) => [dep, ver.replace(/^(\^?\d+)\..*$/, "$1")])) } : {});
|
|
1964
1985
|
pkg.devDependencies = devDepsMap;
|
|
1965
1986
|
return safeWriteFileSync(pkgPath, `${JSON.stringify(pkg, null, 4)}\n`);
|
|
1966
1987
|
}).map(() => projectName);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bryanchu10/create-template-ts",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"description": "Scaffold a modular TypeScript project for scripts and tooling",
|
|
6
6
|
"author": "Bryan Chu <bryanchu10@gmail.com> (https://github.com/bryanchu10)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"build": "rolldown -c",
|
|
26
26
|
"lint": "eslint",
|
|
27
27
|
"lint:fix": "eslint --fix",
|
|
28
|
+
"test": "vitest",
|
|
29
|
+
"test:run": "vitest run",
|
|
28
30
|
"release": "release-it"
|
|
29
31
|
},
|
|
30
32
|
"dependencies": {
|
|
@@ -40,6 +42,7 @@
|
|
|
40
42
|
"release-it": "^20.2.0",
|
|
41
43
|
"rolldown": "^1.0.3",
|
|
42
44
|
"tsx": "^4.22.3",
|
|
43
|
-
"typescript": "^6.0.3"
|
|
45
|
+
"typescript": "^6.0.3",
|
|
46
|
+
"vitest": "^4.1.8"
|
|
44
47
|
}
|
|
45
48
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
id-token: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
publish:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- uses: pnpm/action-setup@v4
|
|
18
|
+
with:
|
|
19
|
+
version: latest
|
|
20
|
+
|
|
21
|
+
- uses: actions/setup-node@v4
|
|
22
|
+
with:
|
|
23
|
+
node-version: lts/*
|
|
24
|
+
registry-url: https://registry.npmjs.org
|
|
25
|
+
|
|
26
|
+
- run: pnpm install
|
|
27
|
+
- run: pnpm build
|
|
28
|
+
|
|
29
|
+
- run: npm publish --access public --provenance
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
git: {
|
|
3
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
4
|
+
commitMessage: "chore: release ${version}",
|
|
5
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
6
|
+
tagName: "v${version}",
|
|
7
|
+
},
|
|
8
|
+
github: {
|
|
9
|
+
release: false,
|
|
10
|
+
},
|
|
11
|
+
npm: {
|
|
12
|
+
publish: false,
|
|
13
|
+
},
|
|
14
|
+
plugins: {
|
|
15
|
+
"@release-it/conventional-changelog": {
|
|
16
|
+
preset: "conventionalcommits",
|
|
17
|
+
infile: "CHANGELOG.md",
|
|
18
|
+
writerOpts: {
|
|
19
|
+
formatDate: date =>
|
|
20
|
+
new Date(date).toLocaleDateString("sv-SE", {
|
|
21
|
+
timeZone: new Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
22
|
+
}),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Disable the default formatter, use eslint instead
|
|
3
|
+
"prettier.enable": false,
|
|
4
|
+
"editor.formatOnSave": false,
|
|
5
|
+
|
|
6
|
+
// Auto fix
|
|
7
|
+
"editor.codeActionsOnSave": {
|
|
8
|
+
"source.fixAll.eslint": "explicit",
|
|
9
|
+
"source.organizeImports": "never"
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
// Enable eslint for all supported languages
|
|
13
|
+
"eslint.validate": [
|
|
14
|
+
"javascript",
|
|
15
|
+
"javascriptreact",
|
|
16
|
+
"typescript",
|
|
17
|
+
"typescriptreact",
|
|
18
|
+
"vue",
|
|
19
|
+
"html",
|
|
20
|
+
"markdown",
|
|
21
|
+
"json",
|
|
22
|
+
"jsonc",
|
|
23
|
+
"yaml",
|
|
24
|
+
"toml",
|
|
25
|
+
"xml",
|
|
26
|
+
"gql",
|
|
27
|
+
"graphql",
|
|
28
|
+
"astro",
|
|
29
|
+
"svelte",
|
|
30
|
+
"css",
|
|
31
|
+
"less",
|
|
32
|
+
"scss",
|
|
33
|
+
"pcss",
|
|
34
|
+
"postcss"
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import antfu from "@antfu/eslint-config";
|
|
2
|
+
|
|
3
|
+
export default antfu(
|
|
4
|
+
{
|
|
5
|
+
typescript: true,
|
|
6
|
+
stylistic: {
|
|
7
|
+
indent: 4,
|
|
8
|
+
quotes: "double",
|
|
9
|
+
braceStyle: "stroustrup",
|
|
10
|
+
semi: true,
|
|
11
|
+
overrides: {
|
|
12
|
+
"style/jsx-one-expression-per-line": ["error", { allow: "non-jsx" }],
|
|
13
|
+
"style/jsx-first-prop-new-line": ["error", "never"],
|
|
14
|
+
"style/jsx-max-props-per-line": "off",
|
|
15
|
+
"style/jsx-closing-bracket-location": ["error", "after-props"],
|
|
16
|
+
"style/operator-linebreak": ["error", "before"],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
rules: {
|
|
22
|
+
"new-cap": ["error", {
|
|
23
|
+
capIsNew: true,
|
|
24
|
+
newIsCap: true,
|
|
25
|
+
properties: true,
|
|
26
|
+
}],
|
|
27
|
+
"no-shadow": "error",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
files: ["pnpm-workspace.yaml"],
|
|
32
|
+
rules: {
|
|
33
|
+
"pnpm/yaml-enforce-settings": ["error", { settings: { shellEmulator: true } }],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
files: ["**/*.yml", "**/*.yaml"],
|
|
38
|
+
rules: {
|
|
39
|
+
"yaml/indent": ["error", 2],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"exports": {
|
|
4
|
+
".": {
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"import": "./dist/index.js"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsdown",
|
|
15
|
+
"dev": "tsdown --watch",
|
|
16
|
+
"test": "vitest",
|
|
17
|
+
"test:run": "vitest run",
|
|
18
|
+
"check": "tsc --noEmit",
|
|
19
|
+
"lint": "eslint",
|
|
20
|
+
"lint:fix": "eslint --fix",
|
|
21
|
+
"release": "release-it"
|
|
22
|
+
}
|
|
23
|
+
}
|