New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More →
Socket
Sign inDemoInstall
Socket

@yumemi-inc/statictrace

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yumemi-inc/statictrace - npm Package Compare versions

Comparing version 1.0.0-beta.14 to 1.0.0-beta.15

2

package.json
{
"name": "@yumemi-inc/statictrace",
"version": "1.0.0-beta.14",
"version": "1.0.0-beta.15",
"description": "A library for semi-automatic static testing.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -7,6 +7,12 @@ # statictrace

## Usage
## Installation
įžåœ¨ã¯ã€ã‚Ŋãƒŧ゚からビãƒĢドするäģĨ外ぎäŊŋį”¨æ–šæŗ•ãŒã‚りぞせん。
### Install
`npm install @yumemi-inc/statictrace`
`statictrace`はプロジェクトごとãĢイãƒŗ゚トãƒŧãƒĢできるし、グロãƒŧバãƒĢãĒãƒ‘ãƒƒã‚ąãƒŧジとしãĻもイãƒŗ゚トãƒŧãƒĢできぞす。
### Build from source
```

@@ -17,13 +23,12 @@ pnpm install

### Use as CLI
### `ts-node`
```
pnpm run build
pnpm run parse -- -p /absolute/path/to/tsconfig.json
`pnpx ts-node src/lib.ts -p /absolute/path/to/tsconfig.json`
```
`ts-node`ぎ場合:
### Use as CLI
```
`pnpx ts-node src/lib.ts -p /absolute/path/to/tsconfig.json`
statictrace -- -p /absolute/path/to/tsconfig.json
```

@@ -33,2 +38,6 @@

```
TS_PROJECT_CONFIG=/absolute/path/to/tsconfig.json
```
**そぎäģ–ぎã‚Ēãƒ—ã‚ˇãƒ§ãƒŗ**

@@ -38,6 +47,62 @@

### äŊŋい斚
`statictrace`は、開į™ēč€…ãŒį‰šæŽŠãĒã‚ŗãƒĄãƒŗトでヒãƒŗトしたįŽ‡æ‰€ã‹ã‚‰ã‚ŗãƒŧドぎ静įš„ãĒ分析をはじめる。䞋えばäģĨ下ぎようãĢį™ģéŒ˛ãƒ•ãƒ­ãƒŧを分析するためãĢ、フロãƒŧãŒã¯ã˜ãžã‚‹ã“ã¨ã‚’čĄ¨ã™ãƒ’ãƒŗト (`@entrypoint フロãƒŧぎ名前`) をé–ĸ数ãĢ JSDoc åŊĸåŧã§čŋŊ加しぞす。
```ts
/**
* @entrypoint Registration
*/
function startRegistration() {
processRegistration();
finishRegistration();
untracedFunction();
cleanupSomething();
}
```
TS_PROJECT_CONFIG=/absolute/path/to/tsconfig.json
これだけではäŊ•ã‚‚ã‚ĸã‚ĻトプットされãĒいが、`statictrace` は `startRegistration()` ぎ中でå‘ŧばれるé–ĸæ•°ã‚„ãƒĄã‚ŊッドをすずãĻæŠŠæĄã—ãžã™ã€‚é–‹į™ēč€…ãŒãƒ†ã‚šãƒˆã‚„ãƒ‰ã‚­ãƒĨãƒĄãƒŗトぎį›Žįš„で、å‘ŧãŗå‡ēしぎ有į„Ąãƒģ順į•ĒãƒģčĻĒ子é–ĸäŋ‚ã‚’č¨˜éŒ˛ã—ãŸã„å ´åˆã¯ã€æ°—ãĢãĒるé–ĸæ•°ã¨ãƒĄã‚ŊッドだけåˆĨぎį‰šæŽŠãĒヒãƒŗトでマãƒŧクできる。そぎヒãƒŗトは `@trace`。
```ts
/** @trace */
function processRegistration() {
someRegistrationProcedure();
}
```
これで `statictrace` ã‚’åŽŸčĄŒã™ã‚‹ã¨äģĨ下ぎã‚ĸã‚Ļトプットが垗られるīŧš
```
Entrypoint: Registration
startRegistration
processRegistration
someRegistrationProcedure
```
こぎã‚ĸã‚Ļãƒˆãƒ—ãƒƒãƒˆã‚’ã‚šãƒŠãƒƒãƒ—ã‚ˇãƒ§ãƒƒãƒˆãŽã‚ˆã†ãĢäŊŋãŖãĻ、åĨŊãŋぎテ゚トナイブナãƒĒでãƒĒãƒ•ã‚Ąã‚¯ã‚ŋãƒĒãƒŗã‚°å‰ã¨åžŒãŽåˇŽåˆ†ã§ãƒ•ãƒ­ãƒŧが変わãŖãĻいãĒいことをäŋč¨ŧできる。ぞたは [`mermaid`](https://mermaid-js.github.io/mermaid/#/) としãĻįĩæžœã‚’ã‚ĸã‚ĻトプットできるīŧˆäģĨ下ãĢį”ģ像があるīŧ‰ã€‚
### 例
- デバッã‚Ŧãƒŧぎ゚ã‚ŋックトãƒŦãƒŧ゚ぎようãĢイãƒŗデãƒŗトされたテキ゚トとしãĻã‚ĸã‚Ļトプットするīŧš
```sh
$ statictrace
=======================
Entrypoint: SomeEntrypoint
begin
funcA
funcC
beingNestedEntrypoint
funcA
funcC
funcB
funcB
```
- mermaid グナフとしãĻマãƒŧクダã‚Ļãƒŗãƒ•ã‚Ąã‚¤ãƒĢãĢã‚ĸã‚Ļトプットする: `statictrace -u mermaid > graphs.md`
こぎ場合ぎグナフがäģĨ下ぎようãĢ襨į¤ēされぞすīŧš
![mermaid](./assets/mermaid.png)
### Use API programmatically

@@ -47,14 +112,8 @@

const { run } = require('./build/lib');
const output = run('/absolute/path/to/tsconfig.json');
const output = run('/absolute/path/to/tsconfig.json', 'text');
// ...do something with output
```
#### `run(pathToTsConfig: string, printer?: Printer): any`
#### `run(pathToTsConfig: string, printerType: "text" | "mermaid"): any`
全ãĻãŽãƒ—ãƒ­ã‚¸ã‚§ã‚¯ãƒˆãŽãƒ•ã‚Ąã‚¤ãƒĢをロãƒŧドし、`@entrypoint`か`@trace`でマãƒŧクされãĻいる全ãĻぎé–ĸ数ぎã‚ŗãƒŧãƒĢぎグナフをäŊœã‚‹ã€‚`Printer`は、グナフをプãƒĒãƒŗトīŧˆãĒんらかぎ斚æŗ•ã§čĄ¨į¤ēできるīŧ‰ã“ã¨ã‚’čĄ¨ã™ã‚¤ãƒŗã‚ŋãƒŧフェãƒŧ゚で、そぎイãƒŗã‚ŋãƒŧフェãƒŧã‚šã‚’ implement したもぎãĒらãĒんでもã‚Ēãƒ—ã‚ˇãƒ§ãƒŠãƒĢãĒåŧ•æ•°ã¨ã—ãĻæ¸Ąã™ã“ã¨ãŒã§ããžã™ã€‚äŊ•ã‚‚æ¸Ąã•ãĒかãŖた場合は、č§Ŗ析ぎįĩæžœã‚’`TextPrinter`が文字列としãĻæˆģしぞす。
```ts
interface Printer {
print(graph: Into<Printable>): any;
}
```
全ãĻãŽãƒ—ãƒ­ã‚¸ã‚§ã‚¯ãƒˆãŽãƒ•ã‚Ąã‚¤ãƒĢをロãƒŧドし、`@entrypoint`か`@trace`でマãƒŧクされãĻいる全ãĻぎé–ĸ数ぎã‚ŗãƒŧãƒĢぎグナフをäŊœã‚‹ã€‚įŦŦäēŒãŽåŧ•æ•°ã¨ã—ãĻプãƒĒãƒŗã‚ŋãƒŧã‚ŋイプを指厚する。プãƒĒãƒŗã‚ŋãƒŧというぎは静įš„分析ぎįĩæžœã‚’ãĒんらかぎåŊĸã§čĄ¨į¤ēできるイãƒŗã‚ŋãƒŧフェãƒŧ゚を指しぞす。įžåœ¨ã€į‹Ŧč‡Ēぎ原čŖ…は不可čƒŊで、デフりãƒĢトぎã‚ŋイプから選択するåŋ…čĻãŒã‚る。

@@ -9,6 +9,12 @@ # statictrace

## Usage
## Installation
Currently you can only use this tool by building it from source.
### Install
`npm install @yumemi-inc/statictrace`
You can install `statictrace` either per-project or globally.
### Build from source
```

@@ -19,6 +25,6 @@ pnpm install

With `ts-node`:
### `ts-node`:
```
`pnpx ts-node src/lib.ts -p /absolute/path/to/tsconfig.json`
pnpx ts-node src/lib.ts -p /absolute/path/to/tsconfig.json
```

@@ -35,2 +41,6 @@

```
TS_PROJECT_CONFIG=/absolute/path/to/tsconfig.json
```
**Other options**

@@ -40,10 +50,63 @@

**Examples**
## Usage
- Output the result printed as mermaid graphs to a markdown file: `pnpm run parse -- -u mermaid > graphs.md`
`statictrace` begins static analysis of your code from a point that is explicitly hinted by a developer. For example, if you want to analyse the registration flow like below, you need to add a JSDoc hint to the function where the flow begins: `@entrypoint YourFlowName`.
```ts
/**
* @entrypoint Registration
*/
function startRegistration() {
processRegistration();
finishRegistration();
untracedFunction();
cleanupSomething();
}
```
TS_PROJECT_CONFIG=/absolute/path/to/tsconfig.json
Just doing this produces no output but `statictrace` internally tracks all function and method calls that occur within `startRegistration()` and every function calls within those functions until there are no calls. In other words, it builds a static stacktrace. If there are any particular functions and methods that you want to test or document, for example to know whether some functions are called, their call order and parent/child relationship, you need to mark relevant functions with another special comment: `@trace`.
```ts
/** @trace */
function processRegistration() {
someRegistrationProcedure();
}
```
With this `statictrace` produces the following output:
```
Entrypoint: Registration
startRegistration
processRegistration
someRegistrationProcedure
```
You can use this output as a snapshot of a stacktrace, and use it from your testing library of choice to guarantee that the flow does not change after e.g. refactoring. You can also output the stacktrace as [`mermaid`](https://mermaid-js.github.io/mermaid/#/) graphs for documentation purposes (see picture below).
## Examples
- Output the result as indented text similar to a debugger stacktrace:
```sh
$ statictrace
=======================
Entrypoint: SomeEntrypoint
begin
funcA
funcC
beingNestedEntrypoint
funcA
funcC
funcB
funcB
```
- Output the result printed as mermaid graphs to a markdown file: `statictrace -u mermaid > graphs.md`
This is how rendered mermaid graphs look like:
![mermaid](./assets/mermaid.png)
### Use API programmatically

@@ -53,3 +116,3 @@

const { run } = require('./build/lib');
const output = run('/absolute/path/to/tsconfig.json');
const output = run('/absolute/path/to/tsconfig.json', 'text');
// ...do something with output

@@ -56,0 +119,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡ī¸ by Socket Inc