Skip to content

Commit

Permalink
feat: support $env intellij environment variables access (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnWeber committed Oct 27, 2024
1 parent e457ab5 commit 96d311d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
### Features
- support client certificates on OAuth2 Requests (#802)
- update tough-cookie to remove punycode deprecation warning (#813)
- support $env intellij environment variables access (#811)

## [6.15.1] ( 2024-08-22)
### Features
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/intellij/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './stubs';
export * from './intellijCryptoSupport';
export * from './intellijHttpClient';
export * from './intellijHttpRequest';
export * from './intellijHttpResponse';
export * from './intellijRandom';
export * from './intellijVariables';
export * from './stubs';
30 changes: 30 additions & 0 deletions src/plugins/intellij/api/intellijRandom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import dayjs from 'dayjs';
import { randomEmail, randomText } from '../../../utils';
import { v4 } from 'uuid';

export class IntellijRandom {
alphabetic(length = 10) {
return randomText(length, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz');
}
numeric(length = 10) {
return randomText(length);
}
hexadecimal(length = 10) {
return randomText(length, '1234567890ABCDEF');
}
get email() {
return randomEmail();
}
float(from = 0, to = 100) {
return Math.random() * (to - from) + from;
}
integer(from = 0, to = 100) {
return Math.floor(Math.random() * (to - from) + from);
}
get uuid() {
return v4();
}
date(date: Date = new Date(), format: string | undefined = undefined) {
return dayjs(date).format(format);
}
}
2 changes: 2 additions & 0 deletions src/plugins/intellij/intellijAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ function initIntellijVariables(context: models.ProcessorContext): intellij.Intel
const variables: intellij.IntellijJavascriptGlobal = {
client: new intellij.IntellijHttpClient(context),
crypto: new intellij.IntellijCryptoSupport(),
$random: new intellij.IntellijRandom(),
$env: process.env,
};
if (context.request) {
if (context.httpRegion.response) {
Expand Down

0 comments on commit 96d311d

Please sign in to comment.