-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ts-playground template (#1440)
- Loading branch information
1 parent
b398d20
commit d74b04f
Showing
10 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable import/no-default-export */ | ||
/* eslint-disable import/no-internal-modules */ | ||
|
||
import { toThisDir } from '@noshiro/mono-utils'; | ||
import { defineRollupConfig } from '../../../../configs/define-rollup-config.mjs'; | ||
import tsconfig from './tsconfig.build.json' with { type: 'json' }; | ||
|
||
export default defineRollupConfig({ | ||
configDir: toThisDir(import.meta.url), | ||
outDirRelative: tsconfig.compilerOptions.outDir, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": [ | ||
"../../../../configs/tsconfig/tsconfig.lib.build.json", | ||
"../../../../configs/tsconfig/tsconfig.vite.json" | ||
], | ||
"compilerOptions": { | ||
"outDir": "../esm", | ||
"declarationDir": "../esm", | ||
"rootDir": "../src" | ||
}, | ||
"include": ["../src"], | ||
"exclude": ["../src/**/*.test.mts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": [ | ||
"../../../../configs/tsconfig/tsconfig.test.json", | ||
"../../../../configs/tsconfig/tsconfig.vite.json" | ||
], | ||
"include": ["../src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { toThisDir } from '@noshiro/mono-utils'; | ||
import * as path from 'node:path'; | ||
import { defineConfig } from 'vitest/config'; | ||
|
||
const thisDir: string = toThisDir(import.meta.url); | ||
|
||
// https://github.com/vitest-dev/vitest/blob/v1.5.0/test/import-meta/vite.config.ts | ||
export default defineConfig({ | ||
test: { | ||
globals: true, | ||
dir: path.resolve(thisDir, '../src'), | ||
includeSource: [path.resolve(thisDir, '../src/**/*.mts')], | ||
typecheck: { | ||
tsconfig: path.resolve(thisDir, 'tsconfig.test.json'), | ||
}, | ||
passWithNoTests: true, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** @typedef {import('@noshiro/eslint-configs').FlatConfig} FlatConfig */ | ||
|
||
import { | ||
eslintFlatConfigForTypeScript, | ||
eslintFlatConfigForVitest, | ||
genEsLintRestrictedImportsDefFromDevDependencies, | ||
} from '@noshiro/eslint-configs'; | ||
import { toThisDir } from '@noshiro/mono-utils'; | ||
import * as path from 'node:path'; | ||
import packageJson from './package.json' with { type: 'json' }; | ||
|
||
const thisDir = toThisDir(import.meta.url); | ||
|
||
/** @returns {Promise<readonly FlatConfig[]>} */ | ||
const defineConfig = async () => { | ||
const restrictedImports = | ||
await genEsLintRestrictedImportsDefFromDevDependencies( | ||
packageJson.devDependencies, | ||
); | ||
|
||
/** @type {readonly FlatConfig[]} */ | ||
const configs = [ | ||
...eslintFlatConfigForTypeScript({ | ||
tsconfigRootDir: thisDir, | ||
tsconfigFileName: './tsconfig.json', | ||
packageDirs: [path.resolve(thisDir, '../../..'), thisDir], | ||
}), | ||
eslintFlatConfigForVitest(['src/**/*']), | ||
|
||
{ | ||
rules: { | ||
'@typescript-eslint/no-restricted-imports': [ | ||
'error', | ||
...restrictedImports, | ||
], | ||
}, | ||
}, | ||
]; | ||
|
||
return configs; | ||
}; | ||
|
||
export default defineConfig(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "@noshiro/template-ts-playground", | ||
"version": "1.0.0", | ||
"private": false, | ||
"license": "MIT", | ||
"author": "noshiro-pf <[email protected]>", | ||
"sideEffects": true, | ||
"type": "module", | ||
"scripts": { | ||
"build": "wireit", | ||
"clean": "run-p clean:**", | ||
"clean:build": "rimraf esm", | ||
"clean:wireit": "rimraf .wireit/**", | ||
"fmt": "yarn zz:prettier .", | ||
"lint": "yarn zz:eslint:src", | ||
"lint:fix": "yarn zz:eslint:src --fix", | ||
"start": "wireit", | ||
"test": "yarn zz:vitest run", | ||
"testw": "yarn zz:vitest watch", | ||
"tsc": "yarn type-check", | ||
"tscw": "tsc --noEmit --watch", | ||
"type-check": "tsc --noEmit", | ||
"zz:eslint": "ESLINT_USE_FLAT_CONFIG=true TIMING=1 eslint", | ||
"zz:eslint:print-config": "yarn zz:eslint --print-config src/index.mts", | ||
"zz:eslint:src": "yarn zz:eslint --config eslint.config.js './src/**/*'", | ||
"zz:prettier": "prettier --cache --cache-strategy content --ignore-path ../../../.prettierignore --write", | ||
"zz:vitest": "vitest --config ./configs/vitest.config.ts" | ||
}, | ||
"dependencies": { | ||
"@noshiro/ts-utils": "*" | ||
}, | ||
"devDependencies": { | ||
"@noshiro/eslint-configs": "*", | ||
"@noshiro/mono-utils": "*", | ||
"@noshiro/ts-type-utils": "*" | ||
}, | ||
"wireit": { | ||
"pre-build": { | ||
"command": "run-s clean:build type-check" | ||
}, | ||
"build": { | ||
"dependencies": [ | ||
"pre-build" | ||
], | ||
"command": "rollup --config ./configs/rollup.config.ts --configPlugin typescript --configImportAttributesKey with" | ||
}, | ||
"start": { | ||
"dependencies": [ | ||
"build" | ||
], | ||
"command": "node ./esm/index.mjs" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": [ | ||
"../../../configs/tsconfig/tsconfig.lib.type-check.json", | ||
"../../../configs/tsconfig/tsconfig.dom", | ||
"../../../configs/tsconfig/tsconfig.vite.json" | ||
], | ||
"include": ["./src", "./configs"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// usage: yarn create:slides <new-slides-name> | ||
|
||
import 'zx/globals'; | ||
import { createNewPackageShared } from './create-new-package-shared.mjs'; | ||
|
||
await createNewPackageShared({ | ||
newPackageName: argv._[0], | ||
templatePackageName: 'template-ts-playground', | ||
parentDirFromMonoRoot: '/packages/others', | ||
templateDirName: '/template', | ||
}); |