Skip to content

Commit

Permalink
switch to a tsc and tsx based setup with support for NodeNext m…
Browse files Browse the repository at this point in the history
…odule resolution. (#41)
  • Loading branch information
fubhy authored Nov 5, 2023
1 parent 965c776 commit e08edb1
Show file tree
Hide file tree
Showing 39 changed files with 1,495 additions and 1,963 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-dryers-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/docgen": minor
---

Modernized and switched to a `tsc` and `tsx` based setup with support for `NodeNext` module resolution.
6 changes: 2 additions & 4 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* eslint-disable no-undef */
module.exports = {
ignorePatterns: ["build", "dist", "dtslint", "*.mjs", "docs", "*.md"],
ignorePatterns: ["dist", "*.mjs", "docs", "*.md"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2018,
sourceType: "module",
project: "./tsconfig.eslint.json"
sourceType: "module"
},
settings: {
"import/parsers": {
Expand Down Expand Up @@ -44,7 +43,6 @@ module.exports = {
"sort-destructure-keys/sort-destructure-keys": "error",
"deprecation/deprecation": "off",
"@typescript-eslint/array-type": ["warn", { "default": "generic", "readonly": "generic" }],
"@typescript-eslint/prefer-readonly": "warn",
"@typescript-eslint/member-delimiter-style": 0,
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-types": "off",
Expand Down
31 changes: 7 additions & 24 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,30 @@ on:
jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.17.1]
node-version: [20.9.0]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2
name: Install pnpm
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ matrix.node-version }}
- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- run: pnpm build
- run: pnpm test
- run: pnpm lint
- run: pnpm run docs
- run: pnpm docgen
- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@v1
with:
version: pnpm run version
publish: pnpm exec changeset publish
version: pnpm update-version
publish: pnpm changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
27 changes: 5 additions & 22 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,21 @@ on:
jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.17.1]
node-version: [20.9.0]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pnpm/action-setup@v2
name: Install pnpm
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
cache: pnpm
node-version: ${{ matrix.node-version }}
- uses: pnpm/[email protected]
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- run: pnpm build
- run: pnpm test
- run: pnpm lint
- run: pnpm run docs
- run: pnpm docgen
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
coverage/
*.tsbuildinfo
node_modules/
yarn-error.log
.ultra.cache.json
.DS_Store
tmp/
build/
dist/
.direnv/
39 changes: 24 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,38 @@ The `docgen.json` configuration file allows you to customize `docgen`'s behavior
```json
{
"exclude": ["src/internal/**/*.ts"],
"theme": "mikearnaldi/just-the-docs",
"parseCompilerOptions": {
"strict": true,
"noEmit": true,
"target": "ES2021",
"lib": ["ES2021"],
"strict": true,
"skipLibCheck": true,
"moduleResolution": "Bundler",
"target": "ES2022",
"lib": [
"ES2022",
"DOM"
],
"paths": {
"@effect/<project-name>": ["./src/index.ts"],
"@effect/<project-name>/test/*": ["./test/*"],
"@effect/<project-name>/examples/*": ["./examples/*"],
"@effect/<project-name>/*": ["./src/*"]
"@effect/<project-name>": ["./src/index.js"],
"@effect/<project-name>/test/*": ["./test/*.js"],
"@effect/<project-name>/examples/*": ["./examples/*.js"],
"@effect/<project-name>/*": ["./src/*.js"]
}
},
"examplesCompilerOptions": {
"strict": true,
"noEmit": true,
"target": "ES2021",
"lib": ["ES2021"],
"strict": true,
"skipLibCheck": true,
"moduleResolution": "Bundler",
"target": "ES2022",
"lib": [
"ES2022",
"DOM"
],
"paths": {
"@effect/<project-name>": ["../../src/index.ts"],
"@effect/<project-name>/test/*": ["../../test/*"],
"@effect/<project-name>/examples/*": ["../../examples/*"],
"@effect/<project-name>/*": ["../../src/*"]
"@effect/<project-name>": ["../../src/index.js"],
"@effect/<project-name>/test/*": ["../../test/*.js"],
"@effect/<project-name>/examples/*": ["../../examples/*.js"],
"@effect/<project-name>/*": ["../../src/*.js"]
}
}
}
Expand Down
17 changes: 14 additions & 3 deletions docgen.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
"$schema": "dist/schema.json",
"parseCompilerOptions": "./tsconfig.json",
"examplesCompilerOptions": "./tsconfig.examples.json"
"$schema": "./schema.json",
"exclude": ["bin.ts"],
"parseCompilerOptions": {
"noEmit": true,
"strict": true,
"skipLibCheck": true,
"exactOptionalPropertyTypes": true,
"moduleResolution": "Bundler",
"target": "ES2022",
"lib": [
"ES2022",
"DOM"
]
}
}
4 changes: 2 additions & 2 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ search_enabled: true

# Aux links for the upper right navigation
aux_links:
'@effect/docgen on GitHub':
- 'https://github.com/effect-ts/docgen'
'@effect/docgen on GitHub':
- 'https://github.com/effect-ts/docgen'
2 changes: 1 addition & 1 deletion docs/modules/Config.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Added in v1.0.0
**Signature**

```ts
export declare const ConfigLive: Layer.Layer<Process.Process | FileSystem.FileSystem, Error, Config>
export declare const ConfigLive: Layer.Layer<Process.Process | Path.Path | FileSystem.FileSystem, Error, Config>
```
Added in v1.0.0
Expand Down
14 changes: 7 additions & 7 deletions docs/modules/Domain.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Added in v1.0.0
```ts
export interface Class extends NamedDoc {
readonly _tag: 'Class'
readonly _tag: "Class"
readonly signature: string
readonly methods: ReadonlyArray<Method>
readonly staticMethods: ReadonlyArray<Method>
Expand All @@ -224,7 +224,7 @@ Added in v1.0.0

```ts
export interface Constant extends NamedDoc {
readonly _tag: 'Constant'
readonly _tag: "Constant"
readonly signature: string
}
```
Expand Down Expand Up @@ -273,7 +273,7 @@ export {

```ts
export interface Export extends NamedDoc {
readonly _tag: 'Export'
readonly _tag: "Export"
readonly signature: string
}
```
Expand All @@ -286,7 +286,7 @@ Added in v1.0.0

```ts
export interface Function extends NamedDoc {
readonly _tag: 'Function'
readonly _tag: "Function"
readonly signatures: ReadonlyArray<string>
}
```
Expand All @@ -299,7 +299,7 @@ Added in v1.0.0

```ts
export interface Interface extends NamedDoc {
readonly _tag: 'Interface'
readonly _tag: "Interface"
readonly signature: string
}
```
Expand Down Expand Up @@ -355,7 +355,7 @@ Added in v1.0.0

```ts
export interface Namespace extends NamedDoc {
readonly _tag: 'Namespace'
readonly _tag: "Namespace"
readonly interfaces: ReadonlyArray<Interface>
readonly typeAliases: ReadonlyArray<TypeAlias>
readonly namespaces: ReadonlyArray<Namespace>
Expand All @@ -382,7 +382,7 @@ Added in v1.0.0

```ts
export interface TypeAlias extends NamedDoc {
readonly _tag: 'TypeAlias'
readonly _tag: "TypeAlias"
readonly signature: string
}
```
Expand Down
12 changes: 6 additions & 6 deletions docs/modules/Markdown.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ Added in v1.0.0
**Signature**

```ts
export declare const printModule: (module: Domain.Module, order: number) => string
export declare const printModule: (module: Domain.Module, order: number) => Effect.Effect<never, never, string>
```
**Example**
```ts
import * as Markdown from '@effect/docgen/Markdown'
import * as Domain from '@effect/docgen/Domain'
import { Option } from 'effect'
import * as Markdown from "@effect/docgen/Markdown"
import * as Domain from "@effect/docgen/Domain"
import { Option } from "effect"

const doc = Domain.createNamedDoc('tests', Option.none(), Option.some('1.0.0'), false, [], Option.none())
const m = Domain.createModule(doc, ['src', 'tests.ts'], [], [], [], [], [], [], [])
const doc = Domain.createNamedDoc("tests", Option.none(), Option.some("1.0.0"), false, [], Option.none())
const m = Domain.createModule(doc, ["src", "tests.ts"], [], [], [], [], [], [], [])
console.log(Markdown.printModule(m, 0))
```

Expand Down
4 changes: 2 additions & 2 deletions docs/modules/Parser.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Added in v1.0.0
```ts
export declare const parseFiles: (
files: ReadonlyArray<FileSystem.File>
) => Effect.Effect<Process.Process | Config.Config, string[][], Domain.Module[]>
) => Effect.Effect<Process.Process | Config.Config | Path.Path, string[][], Domain.Module[]>
```
Added in v1.0.0
Expand Down Expand Up @@ -94,7 +94,7 @@ Added in v1.0.0
**Signature**
```ts
export declare const parseModule: Effect.Effect<Config.Config | Source, string[], Domain.Module>
export declare const parseModule: Effect.Effect<Config.Config | Path.Path | Source, string[], Domain.Module>
```
Added in v1.0.0
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

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

8 changes: 6 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
corepackEnable = pkgs.runCommand "corepack-enable" {} ''
mkdir -p $out/bin
${pkgs.nodejs_20}/bin/corepack enable --install-directory $out/bin
'';
in {
formatter = pkgs.alejandra;

devShells = {
default = pkgs.mkShell {
buildInputs = with pkgs; [
nodejs-18_x
nodePackages.pnpm
nodejs_20
corepackEnable
];
};
};
Expand Down
Loading

0 comments on commit e08edb1

Please sign in to comment.