Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 1x 1x 1x 1x 1x 1x 1x | import { javascript, typescript } from 'projen';
import { Eslint } from '../components/eslint.js';
import { NpmConfig } from '../components/npm.js';
import { Nvm } from '../components/nvmrc.js';
import { Prettier } from '../components/prettier.js';
import { Projen } from '../components/projen.js';
import { defaultTsConfig, useTsNodeEsm } from '../components/tsconfig.js';
import { TsUp, TsUpOptions, legacyEntryPoints } from '../components/tsup.js';
import { Vitest, defaultVitestOptions } from '../components/vitest.js';
import { merge } from '../utils/merge.js';
export interface TypeScriptNpmPackageOptions
extends typescript.TypeScriptProjectOptions {
tsUpOptions?: TsUpOptions;
}
export class TypeScriptNpmPackage extends typescript.TypeScriptProject {
private static defaultOptions(
name: string,
repository?: string,
): typescript.TypeScriptProjectOptions {
return {
name,
...Prettier.defaultOptions,
...Projen.defaultOptions,
...defaultVitestOptions(),
...legacyEntryPoints(),
tsconfig: defaultTsConfig(),
releaseToNpm: true,
authorName: 'Ally Murray',
authorEmail: 'allymurray88@gmail.com',
npmAccess: javascript.NpmAccess.PUBLIC,
gitignore: ['.DS_Store', '*yalc*', 'test-reports'],
repository: repository ? `${repository}.git` : undefined,
bugsUrl: repository ? `${repository}/issues` : undefined,
homepage: repository ? `${repository}#readme` : undefined,
jest: false, // Use vitest instead
};
}
constructor(options: TypeScriptNpmPackageOptions) {
const { repository, ...opts } = options;
super(
merge(
TypeScriptNpmPackage.defaultOptions(options.name, options.repository),
opts,
),
);
new Eslint(this);
new TsUp(this, options.tsUpOptions ?? {});
new NpmConfig(this);
new Nvm(this);
new Vitest(this);
useTsNodeEsm(this);
this.npmignore?.addPatterns('.projenrc.ts');
}
postSynthesize(): void {
super.postSynthesize();
}
}
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
export function createTypeScriptNpmPackage(
options: Optional<TypeScriptNpmPackageOptions, 'defaultReleaseBranch'>,
) {
return new TypeScriptNpmPackage({
...options,
defaultReleaseBranch: options.defaultReleaseBranch ?? 'main',
});
}
|