@firefoxic/utils 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.js +2 -0
- package/package.json +16 -8
- package/lib/getProjectRoot.js +0 -16
- package/lib/index.js +0 -3
- package/lib/setGitHubEnvVar.js +0 -16
package/README.md
CHANGED
|
@@ -97,7 +97,7 @@ jobs:
|
|
|
97
97
|
[changelog-url]: https://github.com/firefoxic/utils/blob/main/CHANGELOG.md
|
|
98
98
|
[changelog-image]: https://img.shields.io/badge/CHANGELOG-md-limegreen
|
|
99
99
|
|
|
100
|
-
[npm-url]: https://npmjs.
|
|
100
|
+
[npm-url]: https://www.npmjs.com/package/@firefoxic/utils
|
|
101
101
|
[npm-image]: https://badge.fury.io/js/@firefoxic%2Futils.svg
|
|
102
102
|
|
|
103
103
|
[test-url]: https://github.com/firefoxic/utils/actions
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the path to the project root when deploying to GitHub Pages.
|
|
3
|
+
* Your action should set `REPO_NAME` and `PR_NUMBER` environment variables at the step you need
|
|
4
|
+
* (most likely when building the project).
|
|
5
|
+
* @returns {string} The path to the project directory from the domain root if working in a GitHub CI environment. If not, returns `/`.
|
|
6
|
+
*/
|
|
7
|
+
declare function getProjectRoot(): string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Sets an environment variable in the GitHub Actions environment file.
|
|
11
|
+
* @async
|
|
12
|
+
* @param {string} varName - The name of the environment variable to set.
|
|
13
|
+
* @param {string} varValue - The value of the environment variable to set.
|
|
14
|
+
* @returns {Promise<void>} A promise that resolves when the environment variable has been set.
|
|
15
|
+
* @throws {Error} If the function is called outside of a GitHub Actions environment or if the GITHUB_ENV environment variable is not set.
|
|
16
|
+
*/
|
|
17
|
+
declare function setGitHubEnvVar(varName: string, varValue: string): Promise<void>;
|
|
18
|
+
|
|
19
|
+
export { getProjectRoot, setGitHubEnvVar };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{env as r}from"process";function e(){return!r.CI||!r.REPO_NAME?"":r.PR_NUMBER?`/${r.REPO_NAME}/${r.PR_NUMBER}`:`/${r.REPO_NAME}`}import{appendFile as i}from"fs/promises";import{env as t}from"process";async function E(n,o){if(t.CI){if(!t.GITHUB_ENV)throw new Error("GITHUB_ENV environment variable is not set. This function should only be used in a GitHub Actions environment.");await i(t.GITHUB_ENV,`
|
|
2
|
+
${n}=${o}`)}}export{e as getProjectRoot,E as setGitHubEnvVar};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firefoxic/utils",
|
|
3
3
|
"description": "Collection of useful utilities for JavaScript and Node.js.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.1.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Sergey Artemov",
|
|
@@ -16,20 +16,28 @@
|
|
|
16
16
|
"url": "git://github.com/firefoxic/utils.git"
|
|
17
17
|
},
|
|
18
18
|
"type": "module",
|
|
19
|
-
"exports":
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
20
25
|
"files": [
|
|
21
|
-
"./
|
|
26
|
+
"./dist/"
|
|
22
27
|
],
|
|
23
28
|
"engines": {
|
|
24
|
-
"node": "
|
|
29
|
+
"node": ">=22.18",
|
|
30
|
+
"pnpm": ">=10.30"
|
|
25
31
|
},
|
|
26
32
|
"scripts": {
|
|
27
|
-
"help": "make help"
|
|
28
|
-
"eslint": "eslint"
|
|
33
|
+
"help": "make help"
|
|
29
34
|
},
|
|
30
35
|
"devDependencies": {
|
|
31
|
-
"@firefoxic/
|
|
32
|
-
"
|
|
36
|
+
"@firefoxic/oxlint-config": "^0.1.3",
|
|
37
|
+
"@types/node": "^25.3.0",
|
|
38
|
+
"oxlint": "^1.50.0",
|
|
39
|
+
"tsup": "^8.5.1",
|
|
40
|
+
"typescript": "^5.9.3"
|
|
33
41
|
},
|
|
34
42
|
"keywords": [
|
|
35
43
|
"javascript",
|
package/lib/getProjectRoot.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { env } from "node:process"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Get the path to the project root when deploying to GitHub Pages.
|
|
5
|
-
* Your action should set `REPO_NAME` and `PR_NUMBER` environment variables at the step you need
|
|
6
|
-
* (most likely when building the project).
|
|
7
|
-
*
|
|
8
|
-
* @returns {string} The path to the project directory from the domain root if working in a GitHub CI environment. If not, returns `/`.
|
|
9
|
-
*/
|
|
10
|
-
export function getProjectRoot () {
|
|
11
|
-
if (!env.CI || !env.REPO_NAME) return ``
|
|
12
|
-
|
|
13
|
-
if (!env.PR_NUMBER) return `/${env.REPO_NAME}`
|
|
14
|
-
|
|
15
|
-
return `/${env.REPO_NAME}/${env.PR_NUMBER}`
|
|
16
|
-
}
|
package/lib/index.js
DELETED
package/lib/setGitHubEnvVar.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { appendFile } from "node:fs/promises"
|
|
2
|
-
import { env } from "node:process"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Sets an environment variable in the GitHub Actions environment file.
|
|
6
|
-
*
|
|
7
|
-
* @param {string} varName The name of the environment variable to set.
|
|
8
|
-
* @param {string} varValue The value of the environment variable to set.
|
|
9
|
-
*
|
|
10
|
-
* @returns {Promise<void>}
|
|
11
|
-
*/
|
|
12
|
-
export async function setGitHubEnvVar (varName, varValue) {
|
|
13
|
-
if (!env.CI) return
|
|
14
|
-
|
|
15
|
-
await appendFile(env.GITHUB_ENV, `\n${varName}=${varValue}`)
|
|
16
|
-
}
|