Skip to content

Commit

Permalink
refactor: switch to mono repo
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed Aug 14, 2024
1 parent 067bf94 commit d15c37b
Show file tree
Hide file tree
Showing 66 changed files with 3,009 additions and 2,733 deletions.
8 changes: 0 additions & 8 deletions .commitlintrc.cjs

This file was deleted.

3 changes: 0 additions & 3 deletions .czrc

This file was deleted.

14 changes: 0 additions & 14 deletions .github/workflows/build-node.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/lint-markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run lint:md-full
- run: pnpm run lint:md
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ jobs:
uses: ./.github/workflows/lint-yaml.yml
test_js:
uses: ./.github/workflows/test-js.yml
# FIXME: Type check fails in CI - disable until fixed.
# type_check:
# uses: ./.github/workflows/type-check.yml
typecheck:
uses: ./.github/workflows/typecheck.yml

release:
needs:
Expand All @@ -44,7 +43,7 @@ jobs:
- lint_spelling
- lint_yaml
- test_js
# - type_check
- typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -57,7 +56,7 @@ jobs:
run: pnpm run build

- name: Release
run: pnpm run release
run: pnpm -r --workspace-concurrency=1 exec -- pnpm run release
env:
GITHUB_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
8 changes: 8 additions & 0 deletions .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ jobs:
build
ci
chore
scopes: |
cli
core
rollup-plugin
webpack-loader
deps
dev-deps
peer-deps
requireScope: false
subjectPattern: ^(?![A-Z]).+$ # Don't start with an uppercase character.
subjectPatternError: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
- run: pnpm run test:js-run
- run: pnpm run test
- uses: codecov/codecov-action@v4
9 changes: 6 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
node_modules/

/bin/
/coverage/
/dist/
bin/
coverage/
dist/

tsconfig.tsbuildinfo
rollup.config-*.mjs

*.log
1 change: 0 additions & 1 deletion .husky/commit-msg

This file was deleted.

2 changes: 1 addition & 1 deletion .lintstagedrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"*.?([cm])[jt]s?(x)":
- eslint --fix
- cspell lint --no-progress --show-suggestions --show-context --no-must-find-files --dot
- tsc-files -p tsconfig.build.json --noEmit
- tsc-files -p tsconfig.json --noEmit

"*.md":
- markdownlint-cli2 --fix
Expand Down
2 changes: 1 addition & 1 deletion .markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"$schema": "node_modules/markdownlint-cli2/schema/markdownlint-cli2-config-schema.json",
"gitignore": true,
"globs": ["**/*.md"],
"ignores": ["node_modules", "coverage", "dist", "CHANGELOG.md"],
"ignores": ["**/node_modules", "**/coverage", "**/dist", "**/bin", "**/CHANGELOG.md"],
}
14 changes: 0 additions & 14 deletions .prettierrc.yml

This file was deleted.

13 changes: 1 addition & 12 deletions .releaserc.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
extends: "semantic-release-monorepo"
branches:
- main
- name: next
channel: next
prerelease: next
plugins:
- - "@semantic-release/commit-analyzer"
- preset: angular
Expand All @@ -26,15 +24,6 @@ plugins:
- type: build
scope: peer-deps
release: patch
- type: build
scope: release-patch
release: patch
- type: build
scope: release-minor
release: minor
- type: build
scope: release-major
release: major
- - "@semantic-release/release-notes-generator"
- preset: angular
parserOpts:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2023, Rebecca Stevens
Copyright (c) 2024, Rebecca Stevens
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
120 changes: 10 additions & 110 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<div align="center">

# Deassert
# Deassert Mono Repo

[![npm version](https://img.shields.io/npm/v/deassert.svg)](https://www.npmjs.com/package/deassert)
[![CI](https://github.com/RebeccaStevens/deassert/actions/workflows/release.yml/badge.svg)](https://github.com/RebeccaStevens/deassert/actions/workflows/release.yml)
[![Coverage Status](https://codecov.io/gh/RebeccaStevens/deassert/branch/main/graph/badge.svg?token=MVpR1oAbIT)](https://codecov.io/gh/RebeccaStevens/deassert)\
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
Expand Down Expand Up @@ -59,115 +58,20 @@ Do not try to recover from Assertion Errors. If your error is recoverable, use a
You probably don't want to use this library in your development builds.
It's designed to be used in your production builds.

### Rollup Plugin
### Packages

```js
// rollup.config.js
import { rollupPlugin as deassert } from "deassert";

const isProduction = process.env.NODE_ENV === "production";

export default {
// ...
plugins: isProduction
? [
// ...
deassert({
include: ["**/*.ts"], // If using TypeScript, be sure to include this config option. Otherwise remove it.
}),
]
: [
// ...
],
};
```

### CLI

```sh
npx deassert myfile.js > myfile.deasserted.js
```

Note: Options cannot be provided via the CLI.

### API

```js
import deassert from "deassert";

const result = deassert(code, options);
console.log(result.code);
```

#### Options

##### `modules`

An array of modules to be considered assert modules.
These modules will be what is stripped out.

###### default

```js
["assert", "assert/strict", "node:assert", "node:assert/strict"];
```

##### `sourceMap`

Determines if a source map should be generated.

[MagicString](https://www.npmjs.com/package/magic-string) source map options can be passed in.

###### default

```jsonc
false
```

If `true` is passed, then these options will be used:

```jsonc
{
"hires": true,
}
```

##### `ast`

The AST of the code that is passed in.

Providing this is optional, but if you have the AST already then we can use that instead of generating our own.

###### default

```jsonc
undefined
```

##### `acornOptions`

The options provided to [Acorn](https://www.npmjs.com/package/acorn) to parse the input code. These are not used if an AST is provided.

###### default

```jsonc
{
"sourceType": "module",
"ecmaVersion": "latest",
}
```
- [JS API](./packages/core/) [![npm version](https://img.shields.io/npm/v/deassert.svg)](https://www.npmjs.com/package/deassert)
- [CLI](./packages/cli/) [![npm version](https://img.shields.io/npm/v/deassert-cli.svg)](https://www.npmjs.com/package/deassert-cli)
- [Rollup Plugin](./packages/rollup-plugin/) [![npm version](https://img.shields.io/npm/v/rollup-plugin-deassert.svg)](https://www.npmjs.com/package/rollup-plugin-deassert)
- [Webpack Loader](./packages/webpack-loader/) [![npm version](https://img.shields.io/npm/v/deassert-loader.svg)](https://www.npmjs.com/package/deassert-loader)

## Example

Given the following code that uses assertion calls to enforce known invariants,
some of which may be expensive (line 11):
some of which may be expensive (line 25):

```js
import {
AssertionError,
ok as assert,
fail as assertNever,
} from "node:assert/strict";
import { AssertionError, ok as assert, fail as assertNever } from "node:assert/strict";

const stack = [
{
Expand All @@ -181,8 +85,7 @@ const result = [];

try {
do {
const element =
stack.pop() ?? assertNever("stack is empty (or contains undefined).");
const element = stack.pop() ?? assertNever("stack is empty (or contains undefined).");

switch (element.type) {
case "foo": {
Expand All @@ -192,10 +95,7 @@ try {
}

case "bar": {
assert(
element.children.length === 0,
"bar elements should not have children.",
);
assert(element.children.length === 0, "bar elements should not have children.");
result.push(element.data);
break;
}
Expand Down
4 changes: 1 addition & 3 deletions cspell.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ dictionaries:
- typescript
- project-dictionary

import:
- "@cspell/dict-cryptocurrencies/cspell-ext.json"

ignorePaths:
- .git
- .gitattributes
Expand All @@ -48,6 +45,7 @@ ignorePaths:
- patches
- pnpm-lock.yaml
- project-dictionary.txt
- tsconfig.tsbuildinfo

ignoreRegExpList:
- /\b[a-f0-9]{6}\b/ui # ignore hex color codes
Expand Down
16 changes: 14 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ export default rsEslint(
{
projectRoot: import.meta.dirname,
mode: "library",
typescript: true,
typescript: {
parserOptions: {
projectService: {
allowDefaultProject: ["*.js"],
defaultProject: "./tsconfig.json",
},
},
},
formatters: true,
functional: false,
jsonc: true,
Expand All @@ -14,7 +21,12 @@ export default rsEslint(
yaml: true,
},
{
files: ["src/cli.ts"],
rules: {
"ts/ban-ts-comment": "off",
},
},
{
files: ["packages/cli/src/**/*"],
rules: {
"no-console": "off",
},
Expand Down
Loading

0 comments on commit d15c37b

Please sign in to comment.