Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
e9ae00f5e9 | |||
4cd8bf5c1a | |||
2bba5f75e6 | |||
74bb4a9837 | |||
3286776b48 | |||
bec80e6862 | |||
c2e406964d | |||
c3e3b2d050 | |||
3a68f74c4e | |||
8f4292f402 | |||
61a82f0d03 | |||
2c8f262c0a |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
name: Default (not tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags-ignore:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: code.foss.global/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install pnpm and npmci
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
|
||||||
|
- name: Run npm prepare
|
||||||
|
run: npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
name: Default (tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: code.foss.global/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm publish
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Code quality
|
||||||
|
run: |
|
||||||
|
npmci command npm install -g typescript
|
||||||
|
npmci npm install
|
||||||
|
|
||||||
|
- name: Trigger
|
||||||
|
run: npmci trigger
|
||||||
|
|
||||||
|
- name: Build docs and upload artifacts
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
pnpm install -g @git.zone/tsdoc
|
||||||
|
npmci command tsdoc
|
||||||
|
continue-on-error: true
|
1
.serena/.gitignore
vendored
Normal file
1
.serena/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/cache
|
67
.serena/project.yml
Normal file
67
.serena/project.yml
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
# language of the project (csharp, python, rust, java, typescript, go, cpp, or ruby)
|
||||||
|
# * For C, use cpp
|
||||||
|
# * For JavaScript, use typescript
|
||||||
|
# Special requirements:
|
||||||
|
# * csharp: Requires the presence of a .sln file in the project folder.
|
||||||
|
language: typescript
|
||||||
|
|
||||||
|
# whether to use the project's gitignore file to ignore files
|
||||||
|
# Added on 2025-04-07
|
||||||
|
ignore_all_files_in_gitignore: true
|
||||||
|
# list of additional paths to ignore
|
||||||
|
# same syntax as gitignore, so you can use * and **
|
||||||
|
# Was previously called `ignored_dirs`, please update your config if you are using that.
|
||||||
|
# Added (renamed) on 2025-04-07
|
||||||
|
ignored_paths: []
|
||||||
|
|
||||||
|
# whether the project is in read-only mode
|
||||||
|
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
|
||||||
|
# Added on 2025-04-18
|
||||||
|
read_only: false
|
||||||
|
|
||||||
|
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
|
||||||
|
# Below is the complete list of tools for convenience.
|
||||||
|
# To make sure you have the latest list of tools, and to view their descriptions,
|
||||||
|
# execute `uv run scripts/print_tool_overview.py`.
|
||||||
|
#
|
||||||
|
# * `activate_project`: Activates a project by name.
|
||||||
|
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
|
||||||
|
# * `create_text_file`: Creates/overwrites a file in the project directory.
|
||||||
|
# * `delete_lines`: Deletes a range of lines within a file.
|
||||||
|
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
|
||||||
|
# * `execute_shell_command`: Executes a shell command.
|
||||||
|
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
|
||||||
|
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
|
||||||
|
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
|
||||||
|
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
|
||||||
|
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
|
||||||
|
# * `initial_instructions`: Gets the initial instructions for the current project.
|
||||||
|
# Should only be used in settings where the system prompt cannot be set,
|
||||||
|
# e.g. in clients you have no control over, like Claude Desktop.
|
||||||
|
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
|
||||||
|
# * `insert_at_line`: Inserts content at a given line in a file.
|
||||||
|
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
|
||||||
|
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
|
||||||
|
# * `list_memories`: Lists memories in Serena's project-specific memory store.
|
||||||
|
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
|
||||||
|
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
|
||||||
|
# * `read_file`: Reads a file within the project directory.
|
||||||
|
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
|
||||||
|
# * `remove_project`: Removes a project from the Serena configuration.
|
||||||
|
# * `replace_lines`: Replaces a range of lines within a file with new content.
|
||||||
|
# * `replace_symbol_body`: Replaces the full definition of a symbol.
|
||||||
|
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
|
||||||
|
# * `search_for_pattern`: Performs a search for a pattern in the project.
|
||||||
|
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
|
||||||
|
# * `switch_modes`: Activates modes by providing a list of their names
|
||||||
|
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
|
||||||
|
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
|
||||||
|
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
|
||||||
|
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
|
||||||
|
excluded_tools: []
|
||||||
|
|
||||||
|
# initial prompt for the project. It will always be given to the LLM upon activating the project
|
||||||
|
# (contrary to the memories, which are loaded on demand).
|
||||||
|
initial_prompt: ""
|
||||||
|
|
||||||
|
project_name: "tsrun"
|
39
changelog.md
39
changelog.md
@@ -1,5 +1,44 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2025-10-13 - 1.3.4 - fix(docs)
|
||||||
|
Update README with expanded docs and examples; add pnpm and CI tooling configs
|
||||||
|
|
||||||
|
- Rewrite and expand README: clearer intro, installation, CLI and programmatic usage examples, features and examples, and updated package/project links.
|
||||||
|
- Add packageManager entry to package.json to record pnpm version/hash (pnpm@10.18.1+sha512...).
|
||||||
|
- Add pnpm-workspace.yaml with onlyBuiltDependencies for esbuild.
|
||||||
|
- Add .serena/project.yml and .serena/.gitignore for project metadata and Serena tooling configuration.
|
||||||
|
- Add .claude/settings.local.json to configure local agent permissions.
|
||||||
|
- No functional TypeScript source changes in this commit (runtime implementations remain as placeholders).
|
||||||
|
|
||||||
|
## 2024-10-27 - 1.3.3 - fix(core)
|
||||||
|
removed unused import statement in ts/plugins.ts
|
||||||
|
|
||||||
|
- Cleanup: Removed an unused import statement for tsImport from tsx/esm/api
|
||||||
|
|
||||||
|
## 2024-10-27 - 1.3.2 - fix(core)
|
||||||
|
Replace ts-node with tsx for module handling
|
||||||
|
|
||||||
|
- Removed ts-node and its loader, using tsx for module imports
|
||||||
|
- Simplified import logic by replacing tsx register API call
|
||||||
|
- Updated dependencies in package.json by removing ts-node and typescript
|
||||||
|
|
||||||
|
## 2024-10-27 - 1.3.1 - fix(core)
|
||||||
|
Add console.log to show ts-node options in use
|
||||||
|
|
||||||
|
- Added a console log statement in the ts/loader.ts to display the default ts-node options being used.
|
||||||
|
|
||||||
|
## 2024-10-27 - 1.3.0 - feat(ci)
|
||||||
|
Add Gitea workflows for build and release.
|
||||||
|
|
||||||
|
- Added .gitea/workflows/default_nottags.yaml for non-tag events.
|
||||||
|
- Added .gitea/workflows/default_tags.yaml for tag-based events.
|
||||||
|
- Updated build scripts in package.json to use pnpm.
|
||||||
|
- Refactored imports and exports in TypeScript source for better modularity.
|
||||||
|
|
||||||
|
## 2024-06-24 - 1.2.49 - fix(core)
|
||||||
|
Minor maintenance updates with version bump
|
||||||
|
|
||||||
|
|
||||||
## 2024-06-24 - 1.2.48 - fix(dependencies)
|
## 2024-06-24 - 1.2.48 - fix(dependencies)
|
||||||
Update TypeScript dependency version
|
Update TypeScript dependency version
|
||||||
|
|
||||||
|
20
package.json
20
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@git.zone/tsrun",
|
"name": "@git.zone/tsrun",
|
||||||
"version": "1.2.48",
|
"version": "1.3.4",
|
||||||
"description": "run typescript programs efficiently",
|
"description": "run typescript programs efficiently",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
"tsrun": "./cli.js"
|
"tsrun": "./cli.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tsbuild && node ./cli.js test/test.js sayhello)",
|
"test": "(pnpm run build && node ./cli.js test/test.js sayhello)",
|
||||||
"format": "(gitzone format)",
|
"format": "(gitzone format)",
|
||||||
"build": "(tsbuild)",
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -25,8 +25,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/smartfile": "^11.0.21",
|
"@push.rocks/smartfile": "^11.0.21",
|
||||||
"@push.rocks/smartshell": "^3.0.5",
|
"@push.rocks/smartshell": "^3.0.5",
|
||||||
"ts-node": "^10.9.2",
|
"tsx": "^4.19.2"
|
||||||
"typescript": "5.5.2"
|
|
||||||
},
|
},
|
||||||
"private": false,
|
"private": false,
|
||||||
"files": [
|
"files": [
|
||||||
@@ -43,5 +42,14 @@
|
|||||||
],
|
],
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
]
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://gitlab.com/gitzone/tsrun.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://gitlab.com/gitzone/tsrun/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://gitlab.com/gitzone/tsrun#readme",
|
||||||
|
"packageManager": "pnpm@10.18.1+sha512.77a884a165cbba2d8d1c19e3b4880eee6d2fcabd0d879121e282196b80042351d5eb3ca0935fa599da1dc51265cc68816ad2bddd2a2de5ea9fdf92adbec7cd34"
|
||||||
}
|
}
|
||||||
|
4128
pnpm-lock.yaml
generated
4128
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
2
pnpm-workspace.yaml
Normal file
2
pnpm-workspace.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
onlyBuiltDependencies:
|
||||||
|
- esbuild
|
189
readme.md
189
readme.md
@@ -1,47 +1,172 @@
|
|||||||
# @gitzone/tsrun
|
# @git.zone/tsrun
|
||||||
run typescript programs efficiently
|
|
||||||
|
|
||||||
## Availabililty and Links
|
> Run TypeScript files instantly, without the compilation hassle ⚡
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@gitzone/tsrun)
|
|
||||||
* [gitlab.com (source)](https://gitlab.com/gitzone/tsrun)
|
|
||||||
* [github.com (source mirror)](https://github.com/gitzone/tsrun)
|
|
||||||
* [docs (typedoc)](https://gitzone.gitlab.io/tsrun/)
|
|
||||||
|
|
||||||
## Status for master
|
Execute TypeScript programs on-the-fly with zero configuration. Perfect for scripts, prototyping, and development workflows.
|
||||||
|
|
||||||
Status Category | Status Badge
|
## What is tsrun?
|
||||||
-- | --
|
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
**tsrun** is a lightweight TypeScript execution tool that lets you run `.ts` files directly—no build step required. It's like running JavaScript with `node`, but for TypeScript. Under the hood, tsrun uses [tsx](https://github.com/esbuild-kit/tsx) for lightning-fast execution while keeping your workflow simple and efficient.
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
|
||||||
npm | [](https://lossless.cloud)
|
## Installation
|
||||||
Snyk | [](https://lossless.cloud)
|
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
```bash
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm install -g @git.zone/tsrun
|
||||||
Code Style | [](https://lossless.cloud)
|
```
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
Or as a project dependency:
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
|
||||||
|
```bash
|
||||||
|
npm install --save-dev @git.zone/tsrun
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use TypeScript for best in class instellisense.
|
### 🚀 CLI Usage
|
||||||
|
|
||||||
To simply run a TypeScript file on the fly type
|
Simply run any TypeScript file:
|
||||||
|
|
||||||
```typescript
|
```bash
|
||||||
tsrun myfiletorun.ts
|
tsrun myScript.ts
|
||||||
```
|
```
|
||||||
|
|
||||||
There are options available:
|
Pass arguments to your script transparently:
|
||||||
|
|
||||||
- `--web` will inject browser types. this is useful when testing code with polyfills on node, but that is meant for the browser later on.
|
```bash
|
||||||
|
tsrun myScript.ts --config production --verbose
|
||||||
|
```
|
||||||
|
|
||||||
## Contribution
|
All arguments are passed through to your TypeScript program, just as if you were running it with `node`.
|
||||||
|
|
||||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
### 💻 Programmatic API
|
||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
Import tsrun in your code for dynamic TypeScript execution:
|
||||||
|
|
||||||
## Legal
|
```typescript
|
||||||
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
import { runPath, runCli } from '@git.zone/tsrun';
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
|
||||||
|
// Run a TypeScript file from an absolute or relative path
|
||||||
|
await runPath('./scripts/myScript.ts');
|
||||||
|
|
||||||
|
// Run with path resolution relative to a file URL
|
||||||
|
await runPath('./myScript.ts', import.meta.url);
|
||||||
|
|
||||||
|
// Run in CLI mode programmatically (respects process.argv)
|
||||||
|
await runCli('./myScript.ts');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
✨ **Zero Configuration** - Just point and shoot. No tsconfig tweaking required.
|
||||||
|
|
||||||
|
⚡ **Fast Execution** - Powered by tsx for near-instant TypeScript execution.
|
||||||
|
|
||||||
|
🔄 **Transparent Arguments** - Command line arguments pass through seamlessly to your scripts.
|
||||||
|
|
||||||
|
📦 **Dual Interface** - Use as a CLI tool or import as a library in your code.
|
||||||
|
|
||||||
|
🎯 **TypeScript Native** - Full TypeScript support with excellent IntelliSense.
|
||||||
|
|
||||||
|
## Why tsrun?
|
||||||
|
|
||||||
|
Sometimes you just want to run a TypeScript file without setting up a build pipeline, configuring webpack, or waiting for `tsc` to compile. That's where tsrun shines:
|
||||||
|
|
||||||
|
- **Quick Scripts**: Write and run TypeScript scripts as easily as bash scripts
|
||||||
|
- **Prototyping**: Test ideas without project setup overhead
|
||||||
|
- **Development Workflows**: Integrate TypeScript execution into your tooling
|
||||||
|
- **CI/CD**: Run TypeScript-based build scripts without pre-compilation
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Simple Script
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// hello.ts
|
||||||
|
console.log('Hello from TypeScript! 🎉');
|
||||||
|
|
||||||
|
const greet = (name: string): string => {
|
||||||
|
return `Welcome, ${name}!`;
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(greet('Developer'));
|
||||||
|
```
|
||||||
|
|
||||||
|
Run it:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tsrun hello.ts
|
||||||
|
# Output:
|
||||||
|
# Hello from TypeScript! 🎉
|
||||||
|
# Welcome, Developer!
|
||||||
|
```
|
||||||
|
|
||||||
|
### With Command Line Arguments
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// deploy.ts
|
||||||
|
const environment = process.argv[2] || 'development';
|
||||||
|
const verbose = process.argv.includes('--verbose');
|
||||||
|
|
||||||
|
console.log(`Deploying to ${environment}...`);
|
||||||
|
if (verbose) {
|
||||||
|
console.log('Verbose mode enabled');
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Run it:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tsrun deploy.ts production --verbose
|
||||||
|
# Output:
|
||||||
|
# Deploying to production...
|
||||||
|
# Verbose mode enabled
|
||||||
|
```
|
||||||
|
|
||||||
|
### Programmatic Execution
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// runner.ts
|
||||||
|
import { runPath } from '@git.zone/tsrun';
|
||||||
|
|
||||||
|
const scripts = [
|
||||||
|
'./scripts/setup.ts',
|
||||||
|
'./scripts/migrate.ts',
|
||||||
|
'./scripts/seed.ts'
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const script of scripts) {
|
||||||
|
console.log(`Running ${script}...`);
|
||||||
|
await runPath(script, import.meta.url);
|
||||||
|
console.log(`✓ ${script} completed`);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Package Information
|
||||||
|
|
||||||
|
- **npmjs**: [@git.zone/tsrun](https://www.npmjs.com/package/@git.zone/tsrun)
|
||||||
|
- **Source**: [git.zone](https://git.zone/lossless/tsrun) | [GitLab Mirror](https://gitlab.com/gitzone/tsrun) | [GitHub Mirror](https://github.com/gitzone/tsrun)
|
||||||
|
- **Documentation**: [TypeDoc](https://gitzone.gitlab.io/tsrun/)
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- **Node.js**: >= 16.x
|
||||||
|
- **TypeScript**: >= 3.x (automatically handled by tsx)
|
||||||
|
|
||||||
|
## License and Legal Information
|
||||||
|
|
||||||
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||||
|
|
||||||
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||||
|
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@git.zone/tsrun',
|
name: '@git.zone/tsrun',
|
||||||
version: '1.2.48',
|
version: '1.3.4',
|
||||||
description: 'run typescript programs efficiently'
|
description: 'run typescript programs efficiently'
|
||||||
}
|
}
|
||||||
|
20
ts/index.ts
20
ts/index.ts
@@ -22,21 +22,7 @@ export const runCli = async (pathArg?: string) => {
|
|||||||
// thus when pathArg is specifed -> we only splice 2
|
// thus when pathArg is specifed -> we only splice 2
|
||||||
pathArg ? process.argv.splice(0, 2) : process.argv.splice(0, 3); // this ensures transparent arguments for the child process
|
pathArg ? process.argv.splice(0, 2) : process.argv.splice(0, 3); // this ensures transparent arguments for the child process
|
||||||
|
|
||||||
// lets setup things for execution
|
const tsx = await import('tsx/esm/api');
|
||||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
const unregister = tsx.register();
|
||||||
executor: 'bash',
|
await import(absolutePathToTsFile);
|
||||||
});
|
|
||||||
|
|
||||||
const tsNodeLoaderPath = plugins.path.join(__dirname, 'loader.js');
|
|
||||||
// note: -> reduce on emtpy array does not work
|
|
||||||
// thus check needed before reducing the argv array
|
|
||||||
smartshellInstance.exec(
|
|
||||||
`node --loader ${tsNodeLoaderPath} ${absolutePathToTsFile} ${
|
|
||||||
process.argv.length > 0
|
|
||||||
? process.argv.reduce((prevArg, currentArg) => {
|
|
||||||
return prevArg + ' ' + currentArg;
|
|
||||||
})
|
|
||||||
: ''
|
|
||||||
}`
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
23
ts/loader.ts
23
ts/loader.ts
@@ -1,23 +0,0 @@
|
|||||||
import * as plugins from './plugins.js';
|
|
||||||
import type { CompilerOptions } from 'typescript';
|
|
||||||
|
|
||||||
const defaultTsNodeOptions: plugins.tsNode.CreateOptions = {
|
|
||||||
compilerOptions: {
|
|
||||||
lib: ['dom'],
|
|
||||||
target: <any>'es2022', // Script Target should be a string -> 2 is for ES2015
|
|
||||||
experimentalDecorators: true,
|
|
||||||
useDefineForClassFields: false,
|
|
||||||
esModuleInterop: true,
|
|
||||||
strictNullChecks: false,
|
|
||||||
moduleResolution: <any>'nodenext',
|
|
||||||
module: <any>'nodenext',
|
|
||||||
verbatimModuleSyntax: true,
|
|
||||||
} as CompilerOptions,
|
|
||||||
esm: true,
|
|
||||||
skipIgnore: true,
|
|
||||||
transpileOnly: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const { resolve, load, getFormat, transformSource } = plugins.tsNode.createEsmHooks(
|
|
||||||
plugins.tsNode.register(defaultTsNodeOptions)
|
|
||||||
) as any;
|
|
1
ts/paths.ts
Normal file
1
ts/paths.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export const cwd = process.cwd();
|
@@ -5,11 +5,7 @@ import * as url from 'url';
|
|||||||
export { path, url };
|
export { path, url };
|
||||||
|
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
import * as smartshell from '@push.rocks/smartshell';
|
import * as smartshell from '@push.rocks/smartshell';
|
||||||
|
|
||||||
export { smartshell };
|
export { smartfile, smartshell };
|
||||||
|
|
||||||
// third party scope
|
|
||||||
import * as tsNode from 'ts-node';
|
|
||||||
|
|
||||||
export { tsNode };
|
|
||||||
|
@@ -3,7 +3,12 @@
|
|||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"useDefineForClassFields": false,
|
"useDefineForClassFields": false,
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "ES2022",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "nodenext"
|
"moduleResolution": "NodeNext",
|
||||||
}
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user