-
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.
#61, start an use-cases "stage" for demonstrations.
- Loading branch information
Showing
7 changed files
with
153 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: build-stage-two | ||
on: | ||
push: | ||
paths: | ||
- '*' | ||
- '.github/workflows/**' | ||
- 'stage_2_snapshot/snapshot/source/**' | ||
- 'use-cases/**' | ||
jobs: | ||
build-stage-two: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.x' | ||
- run: npm ci | ||
- run: npm run use-cases | ||
timeout-minutes: 5 | ||
- run: npm run is-repo-clean |
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
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,64 @@ | ||
{ | ||
"env": { | ||
"es2021": true, | ||
"jasmine": true, | ||
"node": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:import/recommended", | ||
"plugin:import/typescript", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-type-checked", | ||
"plugin:@typescript-eslint/stylistic-type-checked" | ||
], | ||
|
||
"overrides": [ | ||
{ | ||
"files": [ | ||
"**/*.ts" | ||
] | ||
} | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 2022, | ||
"sourceType": "module", | ||
"tsconfigRootDir": ".", | ||
"project": true | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"eslint-plugin-tsdoc", | ||
"import" | ||
], | ||
"root": true, | ||
"rules": { | ||
"@typescript-eslint/ban-types": [ | ||
"error", | ||
{ | ||
"types": { | ||
"Function": false | ||
} | ||
} | ||
], | ||
"@typescript-eslint/consistent-type-definitions": "off", | ||
"@typescript-eslint/explicit-function-return-type": ["error"], | ||
"tsdoc/syntax": "warn" | ||
}, | ||
"settings": { | ||
"import/parsers": { | ||
"@typescript-eslint/parser": [".ts"] | ||
}, | ||
"import/resolver": { | ||
"typescript": { | ||
"alwaysTryTypes": true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist` | ||
|
||
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json by default | ||
|
||
"project": "_*/tsconfig.json" | ||
} | ||
} | ||
} | ||
} |
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 @@ | ||
# Use cases | ||
|
||
The files in this directory are demonstrations of `ts-morph-structures` and `ts-morph` in action. These are not test cases. The formal testing is over at this point. | ||
|
||
Instead, I'm going to focus on how to use these libraries to generate TypeScript code. | ||
|
||
As a result, you'll see a lot of console logging when you run this "stage". You'll also see greater numbers of code comments than usual (or at least, I hope so). |
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,5 @@ | ||
export default function buildStringStringMap(): Promise<void> | ||
{ | ||
console.log("Hello World!"); | ||
return Promise.resolve(); | ||
} |
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,42 @@ | ||
import { BuildPromiseSet } from "#utilities/source/BuildPromise.js"; | ||
import { runModule } from "#utilities/source/runModule.js"; | ||
|
||
import buildStringStringMap from "./build/StringStringMap.js"; | ||
|
||
const BPSet = new BuildPromiseSet; | ||
|
||
{ // eslint | ||
const target = BPSet.get("eslint"); | ||
|
||
const args = [ | ||
"-c", "./.eslintrc.json", | ||
"--max-warnings=0", | ||
]; | ||
|
||
args.push("buildStage.ts"); | ||
args.push("build/**/*.ts"); | ||
|
||
target.addTask(async () => { | ||
console.log("starting use cases:eslint"); | ||
await runModule("../node_modules/eslint/bin/eslint.js", args); | ||
}); | ||
} | ||
|
||
{ // use cases | ||
const target = BPSet.get("use cases"); | ||
target.addTask(async () => { | ||
/* Do not use Promise.all() here or PromiseAllParallel, PromiseAllSequence. | ||
The intent of these modules is demonstration of ts-morph-structures, not efficiency or speed. | ||
*/ | ||
await buildStringStringMap(); | ||
}); | ||
} | ||
|
||
BPSet.markReady(); | ||
{ | ||
BPSet.main.addSubtarget("use cases"); | ||
BPSet.main.addSubtarget("eslint"); | ||
} | ||
await BPSet.main.run(); | ||
|
||
export default Promise.resolve(); |