actions / actions/toolkit

Allow to transform programatical to ESM remove circular dependencies @actions/core

Open
#981 2 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

Describe the enhancement
I need to Transform the code programatical to get useable analyseable static code that i can depend on.

Code Snippet
i think the api enhancment is clear every editor will show the correct types at last with my transpiled version

Additional information
I think no one would want to use this directly even if many people do it i am 100% sure they did never watch the code or did try to modify it.

This is the circular dependencie that blocks me partial the solution is clear to isolate the dependencies into the related files.

node_modules/@actions/core/lib/core.js -> node_modules/@actions/core/lib/oidc-utils.js -> node_modules/@actions/core/lib/core.js

i assign my self and will submit a PR i will also clean up this issue later i want now to directly jump into that

Update PR Done

There is now a PR #982 and even a small additional one that fixes a typescript type issue #983

From 3f73efe2a1a2e6e517e2ba59b725605c972eed0a Mon Sep 17 00:00:00 2001
From: Frank Lemanschik <frank@lemanschik.com>
Date: Fri, 21 Jan 2022 16:10:22 +0100
Subject: [PATCH] Closes: #981

---
 packages/core/src/core.ts       | 55 +-------------------------------
 packages/core/src/oidc-utils.ts |  2 +-
 packages/core/src/utils.ts      | 56 +++++++++++++++++++++++++++++++--
 3 files changed, 56 insertions(+), 57 deletions(-)

diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts
index fafe3e6cf..8bf7ddb3a 100644
--- a/packages/core/src/core.ts
+++ b/packages/core/src/core.ts
@@ -1,6 +1,6 @@
 import {issue, issueCommand} from './command'
 import {issueCommand as issueFileCommand} from './file-command'
-import {toCommandProperties, toCommandValue} from './utils'
+import {toCommandProperties, toCommandValue, AnnotationProperties} from './utils'
 
 import * as os from 'os'
 import * as path from 'path'
@@ -33,43 +33,6 @@ export enum ExitCode {
   Failure = 1
 }
 
-/**
- * Optional properties that can be sent with annotatation commands (notice, error, and warning)
- * See: https://docs.github.com/en/rest/reference/checks#create-a-check-run for more information about annotations.
- */
-export interface AnnotationProperties {
-  /**
-   * A title for the annotation.
-   */
-  title?: string
-
-  /**
-   * The path of the file for which the annotation should be created.
-   */
-  file?: string
-
-  /**
-   * The start line for the annotation.
-   */
-  startLine?: number
-
-  /**
-   * The end line for the annotation. Defaults to `startLine` when `startLine` is provided.
-   */
-  endLine?: number
-
-  /**
-   * The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
-   */
-  startColumn?: number
-
-  /**
-   * The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
-   * Defaults to `startColumn` when `startColumn` is provided.
-   */
-  endColumn?: number
-}
-
 //-----------------------------------------------------------------------
 // Variables
 //-----------------------------------------------------------------------
@@ -94,14 +57,6 @@ export function exportVariable(name: string, val: any): void {
   }
 }
 
-/**
- * Registers a secret which will get masked from logs
- * @param secret value of the secret
- */
-export function setSecret(secret: string): void {
-  issueCommand('add-mask', {}, secret)
-}
-
 /**
  * Prepends inputPath to the PATH (for this action and future actions)
  * @param inputPath
@@ -227,14 +182,6 @@ export function isDebug(): boolean {
   return process.env['RUNNER_DEBUG'] === '1'
 }
 
-/**
- * Writes debug message to user log
- * @param message debug message
- */
-export function debug(message: string): void {
-  issueCommand('debug', {}, message)
-}
-
 /**
  * Adds an error issue
  * @param message error issue message. Errors will be converted to string via toString()
diff --git a/packages/core/src/oidc-utils.ts b/packages/core/src/oidc-utils.ts
index e33da5f11..c54897f35 100644
--- a/packages/core/src/oidc-utils.ts
+++ b/packages/core/src/oidc-utils.ts
@@ -3,7 +3,7 @@ import * as actions_http_client from '@actions/http-client'
 import {IRequestOptions} from '@actions/http-client/interfaces'
 import {HttpClient} from '@actions/http-client'
 import {BearerCredentialHandler} from '@actions/http-client/auth'
-import {debug, setSecret} from './core'
+import {debug, setSecret} from './utils'
 interface TokenResponse {
   value?: string
 }
diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts
index c43f38701..5d76a9423 100644
--- a/packages/core/src/utils.ts
+++ b/packages/core/src/utils.ts
@@ -1,8 +1,60 @@
 // We use any as a valid input type
 /* eslint-disable @typescript-eslint/no-explicit-any */
 
-import {AnnotationProperties} from './core'
-import {CommandProperties} from './command'
+import {CommandProperties, issueCommand} from './command'
+
+/**
+ * Optional properties that can be sent with annotatation commands (notice, error, and warning)
+ * See: https://docs.github.com/en/rest/reference/checks#create-a-check-run for more information about annotations.
+ */
+ export interface AnnotationProperties {
+  /**
+   * A title for the annotation.
+   */
+  title?: string
+
+  /**
+   * The path of the file for which the annotation should be created.
+   */
+  file?: string
+
+  /**
+   * The start line for the annotation.
+   */
+  startLine?: number
+
+  /**
+   * The end line for the annotation. Defaults to `startLine` when `startLine` is provided.
+   */
+  endLine?: number
+
+  /**
+   * The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
+   */
+  startColumn?: number
+
+  /**
+   * The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
+   * Defaults to `startColumn` when `startColumn` is provided.
+   */
+  endColumn?: number
+}
+
+/**
+ * Writes debug message to user log
+ * @param message debug message
+ */
+ export function debug(message: string): void {
+  issueCommand('debug', {}, message)
+}
+
+/**
+ * Registers a secret which will get masked from logs
+ * @param secret value of the secret
+ */
+ export function setSecret(secret: string): void {
+  issueCommand('add-mask', {}, secret)
+}
 
 /**
  * Sanitizes an input into a string so it can be passed into issueCommand safely

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing packages/core/src/core.ts, packages/core/src/oidc-utils.ts, and packages/core/src/utils.ts, which are named in the issue's proposed change and patch. Check whether the circular dependency is removed and the TypeScript package remains usable; the issue references PRs #982 and #983, so the work may already be complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.