Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/hot-mice-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ec-ts/twoslash": major
---

Init ESM-only fork of Twoslash for the expressive-code-twoslash project
35 changes: 20 additions & 15 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
# See https://github.com/actions/labeler/tree/main for more information about the labeler action

twoslash:
- changed-files:
- any-glob-to-any-file:
- packages/expressive-code-twoslash/*

css-js-gen:
- changed-files:
- any-glob-to-any-file:
- packages/css-js-gen/*
- changed-files:
- any-glob-to-any-file:
- packages/css-js-gen/*

docs:
- changed-files:
- any-glob-to-any-file:
- docs/*

ec-ts:twoslash:
- changed-files:
- any-glob-to-any-file:
- packages/@ec-ts/twoslash/*

ec-ts:vfs:
- changed-files:
- any-glob-to-any-file:
- packages/@ec-ts/vfs/*
- changed-files:
- any-glob-to-any-file:
- packages/@ec-ts/vfs/*

docs:
- changed-files:
- any-glob-to-any-file:
- docs/*
twoslash:
- changed-files:
- any-glob-to-any-file:
- packages/expressive-code-twoslash/*
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"mondeja",
"nightlies",
"noline",
"ohash",
"omglookatthis",
"peaceiris",
"recompiles",
Expand Down
51 changes: 25 additions & 26 deletions allurerc.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
import { defineConfig } from "allure";

// These are the packages that have tests and should be included in the Allure report. The report will be grouped by parentSuite, suite, and subSuite, and will only include tests that have a label with name "parentSuite" and value `${pkg} Tests`.
const packagesWithTests = ["css-js-gen", "@ec-ts/twoslash", "@ec-ts/vfs"];

// Create a plugins configuration object for each package with tests, using the @allurereport/plugin-awesome plugin. The report will be named `${pkg} Tests`, and will be published to the Allure server.
const pluginsConfig = Object.fromEntries(
packagesWithTests.map((pkg) => [
pkg,
{
import: "@allurereport/plugin-awesome",
options: {
reportName: `${pkg} Tests`,
singleFile: false,
reportLanguage: "en",
open: false,
publish: true,
groupBy: ["parentSuite", "suite", "subSuite"],
filter: ({ labels }) =>
labels.find(({ name, value }) => name === "parentSuite" && value === `${pkg} Tests`),
},
},
]),
);

// Export the Allure configuration object, which includes the plugins configuration for each package with tests, as well as some general settings for the Allure report.
export default defineConfig({
name: "Allure Report",
output: "./allure-report",
Expand All @@ -15,32 +39,7 @@ export default defineConfig({
],
},
plugins: {
"css-js-gen": {
import: "@allurereport/plugin-awesome",
options: {
reportName: "css-js-gen Tests",
singleFile: false,
reportLanguage: "en",
open: false,
publish: true,
groupBy: ["parentSuite", "suite", "subSuite"],
filter: ({ labels }) =>
labels.find(({ name, value }) => name === "parentSuite" && value === "css-js-gen Tests"),
},
},
"@ec-ts/vfs": {
import: "@allurereport/plugin-awesome",
options: {
reportName: "@ec-ts/vfs Tests",
singleFile: false,
reportLanguage: "en",
open: false,
publish: true,
groupBy: ["parentSuite", "suite", "subSuite"],
filter: ({ labels }) =>
labels.find(({ name, value }) => name === "parentSuite" && value === "@ec-ts/vfs Tests"),
},
},
...pluginsConfig,
log: {
options: {
groupBy: "none",
Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"docs:build": "pnpm build && pnpm --filter docs-twoslash build",
"docs:dev": "pnpm build && pnpm --filter docs-twoslash dev",

"build": "pnpm --filter './packages/*' build",
"dev": "pnpm --filter './packages/*' --filter playground -r --parallel dev",
"build": "pnpm --filter './packages/**' build",
"dev": "pnpm --filter './packages/**' --filter playground -r --parallel dev",
"test": "vitest",

"ci:install": "pnpm install --frozen-lockfile",
Expand Down
19 changes: 19 additions & 0 deletions packages/@ec-ts/twoslash/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The MIT License (MIT)

Copyright (c) Microsoft Corporation
Copyright (c) 2023-PRESENT Anthony Fu <https://github.com/antfu>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 changes: 34 additions & 0 deletions packages/@ec-ts/twoslash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<img src="https://twoslash.netlify.app/logo.svg" alt="Twoslash Logo" width="150">

# Twoslash

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![JSDocs][jsdocs-src]][jsdocs-href]
[![License][license-src]][license-href]

> This is an ESM-only fork of Twoslash for [Expressive Code Twoslash](https://github.com/withstudiocms/expressive-code-twoslash)

[📚 Documentation](https://twoslash.netlify.app/) | [⚙️ Migration Guide](https://twoslash.netlify.app/guide/migrate)

A markup format for TypeScript code, ideal for creating self-contained code samples which let the TypeScript compiler do the extra leg-work. Inspired by the [fourslash test system](https://github.com/orta/typescript-notes/blob/master/systems/testing/fourslash.md).

This project is the successor of [`@typescript/twoslash`](https://github.com/microsoft/TypeScript-Website/tree/v2/packages/ts-twoslasher).

## License

MIT License © [Orta Therox](https://github.com/orta), [Anthony Fu](https://github.com/antfu), Microsoft Corporation

<!-- Badges -->

[npm-version-src]: https://img.shields.io/npm/v/twoslash?style=flat&colorA=161514&colorB=EAB836
[npm-version-href]: https://npmjs.com/package/twoslash
[npm-downloads-src]: https://img.shields.io/npm/dm/twoslash?style=flat&colorA=161514&colorB=E66041
[npm-downloads-href]: https://npmjs.com/package/twoslash
[bundle-src]: https://img.shields.io/bundlephobia/minzip/twoslash?style=flat&colorA=161514&colorB=45627B&label=minzip
[bundle-href]: https://bundlephobia.com/result?p=twoslash
[license-src]: https://img.shields.io/github/license/twoslashes/twoslash.svg?style=flat&colorA=161514&colorB=45627B
[license-href]: https://github.com/twoslashes/twoslash/blob/main/LICENSE
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-161514?style=flat&colorA=161514&colorB=EAB836
[jsdocs-href]: https://www.jsdocs.io/package/twoslash
62 changes: 62 additions & 0 deletions packages/@ec-ts/twoslash/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "@ec-ts/twoslash",
"type": "module",
"version": "0.0.0",
"description": "Markup for generating rich type information in your documentation ahead of time",
"author": "TypeScript team",
"license": "MIT",
"homepage": "https://github.com/withstudiocms/expressive-code-twoslash",
"repository": {
"url": "https://github.com/withstudiocms/expressive-code-twoslash",
"type": "git",
"directory": "packages/@ec-ts/twoslash"
},
"bugs": {
"url": "https://github.com/withstudiocms/expressive-code-twoslash/issues"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./core": {
"types": "./dist/core.d.ts",
"import": "./dist/core.js"
},
"./fallback": {
"types": "./dist/fallback.d.ts",
"import": "./dist/fallback.js"
}
},
"typesVersions": {
"*": {
"./core": [
"./dist/core.d.ts"
],
"./fallback": [
"./dist/fallback.d.ts"
],
"*": [
"./dist/index.d.ts"
]
}
},
"files": [
"dist"
],
"scripts": {
"build": "tsdown --config ./tsdown.config.ts",
"dev": "tsdown --config ./tsdown.config.ts --watch --no-clean",
"test": "vitest"
},
"peerDependencies": {
"typescript": "^5.5.0"
},
"dependencies": {
"@ec-ts/vfs": "workspace:^",
"twoslash-protocol": "catalog:twoslash"
},
"devDependencies": {
"ohash": "^2.0.11"
}
}
22 changes: 22 additions & 0 deletions packages/@ec-ts/twoslash/scripts/flag-keys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import fs from "node:fs/promises";
import ts from "typescript";
import { defaultHandbookOptions } from "../src/defaults";
import type { CompilerOptionDeclaration } from "../src/types/options";

async function generateFlagKeys() {
// biome-ignore lint/suspicious/noExplicitAny: This is the design of the Source API
const tsOptionDeclarations = (ts as any).optionDeclarations as CompilerOptionDeclaration[];

const keys = [
...tsOptionDeclarations.map((i) => i.name),
...Object.keys(defaultHandbookOptions),
].sort();

await fs.writeFile(
"src/flag-keys.ts",
`// Generated by scripts/flag-keys.ts\nexport const flagKeys = ${JSON.stringify(keys, null, 2)}`,
"utf-8",
);
}

generateFlagKeys();
Loading
Loading