Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: Use Shared Action to Publish
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- "v[0-9]+.[0-9]+.[0-9]+"

jobs:
publish_to_npm:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Shared Publish to NPM
uses: McCann-Hub/create-typescript-template/.github/shared/npm/publish@master
Expand All @@ -25,7 +25,7 @@ jobs:
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Shared Publish to GHPR
uses: McCann-Hub/create-typescript-template/.github/shared/ghpr/publish@master
Expand All @@ -40,7 +40,7 @@ jobs:
id-token: write # The OIDC ID token is used for authentication with JSR.
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Shared Publish to JSR
if: ${{ hashFiles('deno.json') != '' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- uses: jabez007/create-node-template/.github/shared/node/test@master
with:
Expand Down
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions bin/github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: Use Shared Action to Publish
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- "v[0-9]+.[0-9]+.[0-9]+"

jobs:
publish_to_npm:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Shared Publish to NPM
uses: McCann-Hub/create-typescript-template/.github/shared/npm/publish@master
Expand All @@ -25,7 +25,7 @@ jobs:
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Shared Publish to GHPR
uses: McCann-Hub/create-typescript-template/.github/shared/ghpr/publish@master
Expand All @@ -40,7 +40,7 @@ jobs:
id-token: write # The OIDC ID token is used for authentication with JSR.
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Shared Publish to JSR
if: ${{ hashFiles('deno.json') != '' }}
Expand Down
2 changes: 1 addition & 1 deletion bin/github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- uses: jabez007/create-node-template/.github/shared/node/test@master
with:
Expand Down
104 changes: 64 additions & 40 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,62 +57,58 @@ async function main() {
);
configUpdates = [
{
key: 'declaration',
value: true,
key: 'target',
value: '"ES2019"',
},
{
key: 'declarationMap',
value: true,
key: 'module',
value: '"Node18"',
},
{
key: 'sourceMap',
value: true,
key: 'rootDir',
value: '"./src"',
},
{
key: 'module',
value: '"NodeNext"',
{
key: 'moduleResolution',
value: '"Node16"',
},
{
key: 'target',
value: '"ES2017"',
key: 'baseUrl',
value: '"."',
},
{
key: 'moduleResolution',
value: '"Node16"',
key: 'paths',
value: JSON.stringify({
'@/*': ['src/*'],
'@utils/*': ['src/utils/*'],
}),
},
{
key: 'esModuleInterop',
key: 'rewriteRelativeImportExtensions',
value: true,
},
},
{
key: 'skipLibCheck',
key: 'declaration',
value: true,
},
{
key: 'resolveJsonModule',
key: 'sourceMap',
value: true,
},
{
key: 'outDir',
value: '"./dist"',
},
{
key: 'rootDir',
value: '"./src"',
},
{
key: 'baseUrl',
value: '"."',
key: 'removeComments',
value: false,
},
{
key: 'paths',
value: JSON.stringify({
'@/*': ['src/*'],
'@utils/*': ['src/utils/*'],
}),
key: 'esModuleInterop',
value: true,
},
{
key: 'removeComments',
key: 'skipLibCheck',
value: true,
},
];
Expand All @@ -134,7 +130,7 @@ async function main() {
`},
"include": ["src/**/*"],
"exclude": [
"node_module",
"node_modules",
"dist",
"tests"
]
Expand All @@ -151,11 +147,11 @@ async function main() {
compilerOptions: {
module: 'CommonJS',
moduleResolution: 'Node10',
target: 'ES5',
outDir: './dist/cjs',
declarationDir: './dist/cjs',
target: 'ES2015',
declaration: false,
declarationMap: false,
},
include: ['src/**/*'],
},
null,
2
Expand All @@ -169,11 +165,31 @@ async function main() {
{
extends: './tsconfig.json',
compilerOptions: {
module: 'NodeNext',
moduleResolution: 'NodeNext',
target: 'ES2023',
outDir: './dist/esm',
declarationDir: './dist/esm',
target: 'ES2020',
},
include: ['src/**/*'],
declaration: false,
declarationMap: false,
},
},
null,
2
)
);

console.log('writing tsconfig for Types');
await write(
join(projectWorkingDirectory, 'tsconfig.types.json'),
JSON.stringify(
{
extends: './tsconfig.json',
compilerOptions: {
outDir: './dist/types',
emitDeclarationOnly: true,
declaration: true,
declarationMap: true,
},
},
null,
2
Expand All @@ -195,14 +211,18 @@ async function main() {
await exec('npm pkg set main=./dist/cjs/index.js');

console.log('adding types to package.json');
await exec('npm pkg set types=./dist/cjs/index.d.ts');
await exec('npm pkg set types=./dist/types/index.d.ts');

console.log('adding module to package.json');
await exec('npm pkg set module=./dist/esm/index.js');

console.log('setting type in package.json');
await exec('npm pkg set type=module');

console.log('adding exports in package.json');
await exec('npm pkg set exports["."].import=./dist/esm/index.js');
await exec('npm pkg set exports["."].require=./dist/cjs/index.js');
await exec('npm pkg set exports["."].types=./dist/types/index.d.ts');

console.log('adding files in package.json');
await exec('npm pkg set files[0]=dist/**/*');
Expand All @@ -216,6 +236,7 @@ async function main() {
await exec(
'npm pkg set scripts.build="npm run build:cjs && npm run build:esm"'
);
await exec('npm pkg set scripts.build:types="tsc --project tsconfig.types.json"');

console.log('adding prepublishOnly script');
await exec('npm pkg set scripts.prepublishOnly="npm run build"');
Expand All @@ -227,7 +248,10 @@ async function main() {

console.log('adding prebuild script');
await exec('npm pkg set scripts.prebuild="npm run clean"');
/* END */

console.log('adding postbuild script');
await exec('npm pkg set scripts.postbuild="npm run build:types"');
/* END */

/*
* install tsc-alias
Expand Down Expand Up @@ -324,7 +348,7 @@ async function main() {
extends: './tsconfig.json',
compilerOptions: {
module: 'CommonJS',
target: 'ES2020',
target: 'ES2017',
outDir: './dist/test',
rootDir: './',
noEmit: false,
Expand Down
15 changes: 8 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mccann-hub/create-typescript-template",
"version": "0.3.0",
"version": "0.4.0",
"publishConfig": {
"access": "public"
},
Expand All @@ -11,10 +11,12 @@
"test": "cross-env TSX_TSCONFIG_PATH='./tsconfig.test.json' mocha",
"build:cjs": "tsc --project tsconfig.commonjs.json && tsc-alias -p tsconfig.commonjs.json",
"build:esm": "tsc --project tsconfig.esm.json && tsc-alias -p tsconfig.esm.json",
"build:types": "tsc --project tsconfig.types.json",
"build": "npm run build:cjs && npm run build:esm",
"prepublishOnly": "npm run build",
"clean": "node -e \"require('fs').rmSync('./dist', { recursive: true, force: true })\"",
"prebuild": "npm run clean",
"postbuild": "npm run build:types",
"lint": "eslint . --ext .ts,.js --fix"
},
"keywords": [
Expand All @@ -37,7 +39,7 @@
"npm-publish"
],
"author": "jabez007",
"license": "ISC",
"license": "GPL-3.0-only",
"devDependencies": {
"@types/mocha": "^10.0.9",
"@types/node": "^22.8.2",
Expand All @@ -49,14 +51,15 @@
"tsc-alias": "^1.8.10",
"tsconfig-paths": "^4.2.0",
"tsx": "^4.19.2",
"typescript": "^5.6.3"
"typescript": "^5.8.3"
},
"types": "./dist/cjs/index.d.ts",
"types": "./dist/types/index.d.ts",
"module": "./dist/esm/index.js",
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
"require": "./dist/cjs/index.js",
"types": "./dist/types/index.d.ts"
}
},
"repository": {
Expand Down
12 changes: 5 additions & 7 deletions tsconfig.commonjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "Node10",
"target": "ES5",
"outDir": "./dist/cjs",
"declarationDir": "./dist/cjs",
"target": "ES2015"
},
"include": [
"src/**/*"
]
}
"declaration": false,
"declarationMap": false
}
}
Loading